<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP, DeriveFunctor, MultiWayIf, TupleSections,
    ScopedTypeVariables #-}</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns   #-}</span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-comment">-- | Type subsumption and unification</span><span>
</span><span id="line-14"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Utils.Unify</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-15"></span><span>  </span><span class="hs-comment">-- Full-blown subsumption</span><span>
</span><span id="line-16"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcWrapResult"><span class="hs-identifier">tcWrapResult</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcWrapResultO"><span class="hs-identifier">tcWrapResultO</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcWrapResultMono"><span class="hs-identifier">tcWrapResultMono</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSkolemise"><span class="hs-identifier">tcSkolemise</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSkolemiseScoped"><span class="hs-identifier">tcSkolemiseScoped</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSkolemiseET"><span class="hs-identifier">tcSkolemiseET</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubType"><span class="hs-identifier">tcSubType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubTypeSigma"><span class="hs-identifier">tcSubTypeSigma</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubTypePat"><span class="hs-identifier">tcSubTypePat</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier">tcSubMult</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#checkConstraints"><span class="hs-identifier">checkConstraints</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#checkTvConstraints"><span class="hs-identifier">checkTvConstraints</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#buildImplicationFor"><span class="hs-identifier">buildImplicationFor</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#buildTvImplication"><span class="hs-identifier">buildTvImplication</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#emitResidualTvConstraint"><span class="hs-identifier">emitResidualTvConstraint</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span>  </span><span class="hs-comment">-- Various unifications</span><span>
</span><span id="line-24"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier">unifyType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyKind"><span class="hs-identifier">unifyKind</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier">uType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTcType"><span class="hs-identifier">promoteTcType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#swapOverTyVars"><span class="hs-identifier">swapOverTyVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#canSolveByUnification"><span class="hs-identifier">canSolveByUnification</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span>  </span><span class="hs-comment">--------------------------------</span><span>
</span><span id="line-29"></span><span>  </span><span class="hs-comment">-- Holes</span><span>
</span><span id="line-30"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tcInfer"><span class="hs-identifier">tcInfer</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedListTy"><span class="hs-identifier">matchExpectedListTy</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedTyConApp"><span class="hs-identifier">matchExpectedTyConApp</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedAppTy"><span class="hs-identifier">matchExpectedAppTy</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedFunTys"><span class="hs-identifier">matchExpectedFunTys</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchActualFunTysRho"><span class="hs-identifier">matchActualFunTysRho</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchActualFunTySigma"><span class="hs-identifier">matchActualFunTySigma</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedFunKind"><span class="hs-identifier">matchExpectedFunKind</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#metaTyVarUpdateOK"><span class="hs-identifier">metaTyVarUpdateOK</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#occCheckForErrors"><span class="hs-identifier">occCheckForErrors</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier">MetaTyVarUpdateResult</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html"><span class="hs-identifier">GHC.Core.TyCo.Ppr</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html#debugPprType"><span class="hs-identifier">debugPprType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html"><span class="hs-identifier">GHC.Tc.Utils.TcMType</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html"><span class="hs-identifier">GHC.Tc.Types.Constraint</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#isSystemName"><span class="hs-identifier">isSystemName</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html"><span class="hs-identifier">GHC.Tc.Utils.Instantiate</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Var</span></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Outputable</span></span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#"><span class="hs-identifier">Control.Arrow</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#second"><span class="hs-identifier">second</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
             matchExpected functions
*                                                                      *
************************************************************************

Note [Herald for matchExpectedFunTys]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'herald' always looks like:
   &quot;The equation(s) for 'f' have&quot;
   &quot;The abstraction (\x.e) takes&quot;
   &quot;The section (+ x) expects&quot;
   &quot;The function 'f' is applied to&quot;

This is used to construct a message of form

   The abstraction `\Just 1 -&gt; ...' takes two arguments
   but its type `Maybe a -&gt; a' has only one

   The equation(s) for `f' have two arguments
   but its type `Maybe a -&gt; a' has only one

   The section `(f 3)' requires 'f' to take two arguments
   but its type `Int -&gt; Int' has only one

   The function 'f' is applied to two arguments
   but its type `Int -&gt; Int' has only one

When visible type applications (e.g., `f @Int 1 2`, as in #13902) enter the
picture, we have a choice in deciding whether to count the type applications as
proper arguments:

   The function 'f' is applied to one visible type argument
     and two value arguments
   but its type `forall a. a -&gt; a` has only one visible type argument
     and one value argument

Or whether to include the type applications as part of the herald itself:

   The expression 'f @Int' is applied to two arguments
   but its type `Int -&gt; Int` has only one

The latter is easier to implement and is arguably easier to understand, so we
choose to implement that option.

Note [matchExpectedFunTys]
~~~~~~~~~~~~~~~~~~~~~~~~~~
matchExpectedFunTys checks that a sigma has the form
of an n-ary function.  It passes the decomposed type to the
thing_inside, and returns a wrapper to coerce between the two types

It's used wherever a language construct must have a functional type,
namely:
        A lambda expression
        A function definition
     An operator section

This function must be written CPS'd because it needs to fill in the
ExpTypes produced for arguments before it can fill in the ExpType
passed in.

-}</span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span class="hs-comment">-- Use this one when you have an &quot;expected&quot; type.</span><span>
</span><span id="line-143"></span><span class="hs-comment">-- This function skolemises at each polytype.</span><span>
</span><span id="line-144"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedFunTys"><span class="hs-identifier hs-type">matchExpectedFunTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621681080466"><span class="annot"><a href="#local-6989586621681080466"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-operator">.</span><span>
</span><span id="line-145"></span><span>                       </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>   </span><span class="hs-comment">-- See Note [Herald for matchExpectedFunTys]</span><span>
</span><span id="line-146"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span>
</span><span id="line-147"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-148"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>      </span><span class="hs-comment">-- Skolemised</span><span>
</span><span id="line-149"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpSigmaType"><span class="hs-identifier hs-type">ExpSigmaType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080466"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681080466"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-151"></span><span class="hs-comment">-- If    matchExpectedFunTys n ty = (_, wrap)</span><span>
</span><span id="line-152"></span><span class="hs-comment">-- then  wrap : (t1 -&gt; ... -&gt; tn -&gt; ty_r) ~&gt; ty,</span><span>
</span><span id="line-153"></span><span class="hs-comment">--   where [t1, ..., tn], ty_r are passed to the thing_inside</span><span>
</span><span id="line-154"></span><span id="matchExpectedFunTys"><span class="annot"><span class="annottext">matchExpectedFunTys :: forall a.
SDoc
-&gt; UserTypeCtxt
-&gt; Int
-&gt; ExpRhoType
-&gt; ([Scaled ExpRhoType] -&gt; ExpRhoType -&gt; TcM a)
-&gt; TcM (HsWrapper, a)
</span><a href="GHC.Tc.Utils.Unify.html#matchExpectedFunTys"><span class="hs-identifier hs-var hs-var">matchExpectedFunTys</span></a></span></span><span> </span><span id="local-6989586621681080073"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681080073"><span class="hs-identifier hs-var">herald</span></a></span></span><span> </span><span id="local-6989586621681080072"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681080072"><span class="hs-identifier hs-var">ctx</span></a></span></span><span> </span><span id="local-6989586621681080071"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080071"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span id="local-6989586621681080070"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681080070"><span class="hs-identifier hs-var">orig_ty</span></a></span></span><span> </span><span id="local-6989586621681080069"><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; ExpRhoType -&gt; TcM a
</span><a href="#local-6989586621681080069"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-155"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681080070"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-156"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681080067"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080067"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; TcType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080071"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080067"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-157"></span><span>      </span><span class="annot"><span class="annottext">ExpRhoType
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; ExpRhoType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080065"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080071"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681080070"><span class="hs-identifier hs-var">orig_ty</span></a></span><span>
</span><span id="line-158"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-159"></span><span>    </span><span class="hs-comment">-- Skolemise any foralls /before/ the zero-arg case</span><span>
</span><span id="line-160"></span><span>    </span><span class="hs-comment">-- so that we guarantee to return a rho-type</span><span>
</span><span id="line-161"></span><span>    </span><span id="local-6989586621681080066"><span class="annot"><span class="annottext">go :: [Scaled ExpRhoType] -&gt; Int -&gt; TcType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080066"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681080050"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080050"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span></span><span> </span><span id="local-6989586621681080049"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080049"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681080048"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080048"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-162"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681080047"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681080047"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681080046"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681080046"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([TcTyVar], ThetaType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitSigmaTy"><span class="hs-identifier hs-var">tcSplitSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080048"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-163"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681080047"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681080046"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-164"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681080041"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681080041"><span class="hs-identifier hs-var">wrap_gen</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681080040"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681080040"><span class="hs-identifier hs-var">wrap_res</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681080039"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681080039"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
-&gt; TcType
-&gt; (TcType -&gt; TcM (HsWrapper, a))
-&gt; TcM (HsWrapper, (HsWrapper, a))
forall result.
UserTypeCtxt
-&gt; TcType -&gt; (TcType -&gt; TcM result) -&gt; TcM (HsWrapper, result)
</span><a href="GHC.Tc.Utils.Unify.html#tcSkolemise"><span class="hs-identifier hs-var">tcSkolemise</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681080072"><span class="hs-identifier hs-var">ctx</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080048"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">((TcType -&gt; TcM (HsWrapper, a)) -&gt; TcM (HsWrapper, (HsWrapper, a)))
-&gt; (TcType -&gt; TcM (HsWrapper, a))
-&gt; TcM (HsWrapper, (HsWrapper, a))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681080038"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080038"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-165"></span><span>                                               </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; TcType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080050"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080049"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080038"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-166"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, a) -&gt; TcM (HsWrapper, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681080041"><span class="hs-identifier hs-var">wrap_gen</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681080040"><span class="hs-identifier hs-var">wrap_res</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681080039"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span>    </span><span class="hs-comment">-- No more args; do this /before/ tcView, so</span><span>
</span><span id="line-169"></span><span>    </span><span class="hs-comment">-- that we do not unnecessarily unwrap synonyms</span><span>
</span><span id="line-170"></span><span>    </span><span class="annot"><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681080036"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080036"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621681080035"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080035"><span class="hs-identifier hs-var">rho_ty</span></a></span></span><span>
</span><span id="line-171"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681080034"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681080034"><span class="hs-identifier hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; ExpRhoType -&gt; TcM a
</span><a href="#local-6989586621681080069"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; [Scaled ExpRhoType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080036"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType
</span><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier hs-var">mkCheckExpType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080035"><span class="hs-identifier hs-var">rho_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-172"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, a) -&gt; TcM (HsWrapper, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681080034"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-173"></span><span>
</span><span id="line-174"></span><span>    </span><span class="annot"><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681080030"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080030"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span></span><span> </span><span id="local-6989586621681080029"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080029"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681080028"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080028"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-175"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681080027"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080027"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080028"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; TcType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080030"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080029"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080027"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span>    </span><span class="annot"><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681080025"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080025"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span></span><span> </span><span id="local-6989586621681080024"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080024"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_mult :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681080021"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080021"><span class="hs-identifier hs-var">mult</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_af :: TcType -&gt; AnonArgFlag
</span><a href="GHC.Core.TyCo.Rep.html#ft_af"><span class="hs-identifier hs-var">ft_af</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681080019"><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681080019"><span class="hs-identifier hs-var">af</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_arg :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681080017"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080017"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681080015"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080015"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-178"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">af</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">VisArg</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-179"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681080011"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681080011"><span class="hs-identifier hs-var">wrap_res</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681080010"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681080010"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; TcType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType -&gt; Scaled ExpRhoType
forall a. TcType -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080021"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">(ExpRhoType -&gt; Scaled ExpRhoType)
-&gt; ExpRhoType -&gt; Scaled ExpRhoType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType
</span><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier hs-var">mkCheckExpType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080017"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Scaled ExpRhoType -&gt; [Scaled ExpRhoType] -&gt; [Scaled ExpRhoType]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080025"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-180"></span><span>                                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080024"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080015"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-181"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681080008"><span class="annot"><span class="annottext">fun_wrap :: HsWrapper
</span><a href="#local-6989586621681080008"><span class="hs-identifier hs-var hs-var">fun_wrap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper
-&gt; HsWrapper -&gt; Scaled TcType -&gt; TcType -&gt; SDoc -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpFun"><span class="hs-identifier hs-var">mkWpFun</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681080011"><span class="hs-identifier hs-var">wrap_res</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Scaled TcType
forall a. TcType -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080021"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080017"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681080015"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681080006"><span class="hs-identifier hs-var">doc</span></a></span><span>
</span><span id="line-182"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, a) -&gt; TcM (HsWrapper, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681080008"><span class="hs-identifier hs-var">fun_wrap</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681080010"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-183"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-184"></span><span>        </span><span id="local-6989586621681080006"><span class="annot"><span class="annottext">doc :: SDoc
</span><a href="#local-6989586621681080006"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;When inferring the argument type of a function with type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-185"></span><span>              </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExpRhoType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681080070"><span class="hs-identifier hs-var">orig_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span>    </span><span class="annot"><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681080000"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080000"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span></span><span> </span><span id="local-6989586621681079999"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079999"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079998"><span class="annot"><span class="annottext">ty :: TcType
</span><a href="#local-6989586621681079998"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079996"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079996"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-188"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079996"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-189"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079994"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079994"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var">readMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079996"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-190"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079994"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-191"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681079991"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079991"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; TcType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080000"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079999"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079991"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-192"></span><span>               </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; ExpRhoType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080065"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681080000"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079999"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType
</span><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier hs-var">mkCheckExpType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079998"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span>       </span><span class="hs-comment">-- In all other cases we bale out into ordinary unification</span><span>
</span><span id="line-195"></span><span>       </span><span class="hs-comment">-- However unlike the meta-tyvar case, we are sure that the</span><span>
</span><span id="line-196"></span><span>       </span><span class="hs-comment">-- number of arguments doesn't match arity of the original</span><span>
</span><span id="line-197"></span><span>       </span><span class="hs-comment">-- type, so we can add a bit more context to the error message</span><span>
</span><span id="line-198"></span><span>       </span><span class="hs-comment">-- (cf #7869).</span><span>
</span><span id="line-199"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-200"></span><span>       </span><span class="hs-comment">-- It is not always an error, because specialized type may have</span><span>
</span><span id="line-201"></span><span>       </span><span class="hs-comment">-- different arity, for example:</span><span>
</span><span id="line-202"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-203"></span><span>       </span><span class="hs-comment">-- &gt; f1 = f2 'a'</span><span>
</span><span id="line-204"></span><span>       </span><span class="hs-comment">-- &gt; f2 :: Monad m =&gt; m Bool</span><span>
</span><span id="line-205"></span><span>       </span><span class="hs-comment">-- &gt; f2 = undefined</span><span>
</span><span id="line-206"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-207"></span><span>       </span><span class="hs-comment">-- But in that case we add specialized type into error context</span><span>
</span><span id="line-208"></span><span>       </span><span class="hs-comment">-- anyway, because it may be useful. See also #9605.</span><span>
</span><span id="line-209"></span><span>    </span><span class="annot"><a href="#local-6989586621681080066"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079989"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079989"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span></span><span> </span><span id="local-6989586621681079988"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079988"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079987"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079987"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv -&gt; TcM (TidyEnv, SDoc))
-&gt; TcM (HsWrapper, a) -&gt; TcM (HsWrapper, a)
forall a. (TidyEnv -&gt; TcM (TidyEnv, SDoc)) -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxtM"><span class="hs-identifier hs-var">addErrCtxtM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; TcType -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="#local-6989586621681079985"><span class="hs-identifier hs-var">mk_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079989"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079987"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM (HsWrapper, a) -&gt; TcM (HsWrapper, a))
-&gt; TcM (HsWrapper, a) -&gt; TcM (HsWrapper, a)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-210"></span><span>                          </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; Int -&gt; ExpRhoType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080065"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079989"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079988"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType
</span><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier hs-var">mkCheckExpType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079987"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-211"></span><span>
</span><span id="line-212"></span><span>    </span><span class="hs-comment">------------</span><span>
</span><span id="line-213"></span><span>    </span><span class="annot"><a href="#local-6989586621681080065"><span class="hs-identifier hs-type">defer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpSigmaType"><span class="hs-identifier hs-type">ExpSigmaType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681080466"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-214"></span><span>    </span><span id="local-6989586621681080065"><span class="annot"><span class="annottext">defer :: [Scaled ExpRhoType] -&gt; Int -&gt; ExpRhoType -&gt; TcM (HsWrapper, a)
</span><a href="#local-6989586621681080065"><span class="hs-identifier hs-var hs-var">defer</span></a></span></span><span> </span><span id="local-6989586621681079984"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079984"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span></span><span> </span><span id="local-6989586621681079983"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079983"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079982"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079982"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span>
</span><span id="line-215"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079981"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079981"><span class="hs-identifier hs-var">more_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Scaled ExpRhoType)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Scaled ExpRhoType]
forall (m :: * -&gt; *) a. Applicative m =&gt; Int -&gt; m a -&gt; m [a]
</span><a href="../../base/src/Control.Monad.html#replicateM"><span class="hs-identifier hs-var">replicateM</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079983"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType -&gt; Scaled ExpRhoType
forall a. TcType -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.Type.html#mkScaled"><span class="hs-identifier hs-var">mkScaled</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; ExpRhoType -&gt; Scaled ExpRhoType)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (ExpRhoType -&gt; Scaled ExpRhoType)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="GHC.Builtin.Types.html#multiplicityTy"><span class="hs-identifier hs-var">multiplicityTy</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) (ExpRhoType -&gt; Scaled ExpRhoType)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ExpRhoType
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Scaled ExpRhoType)
forall (f :: * -&gt; *) a b. Applicative f =&gt; f (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) ExpRhoType
</span><a href="GHC.Tc.Utils.TcMType.html#newInferExpType"><span class="hs-identifier hs-var">newInferExpType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-216"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079974"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079974"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) ExpRhoType
</span><a href="GHC.Tc.Utils.TcMType.html#newInferExpType"><span class="hs-identifier hs-var">newInferExpType</span></a></span><span>
</span><span id="line-217"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079973"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681079973"><span class="hs-identifier hs-var">result</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; ExpRhoType -&gt; TcM a
</span><a href="#local-6989586621681080069"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; [Scaled ExpRhoType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079984"><span class="hs-identifier hs-var">acc_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; [Scaled ExpRhoType] -&gt; [Scaled ExpRhoType]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079981"><span class="hs-identifier hs-var">more_arg_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079974"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-218"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079972"><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079972"><span class="hs-identifier hs-var">more_arg_tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Scaled ExpRhoType
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Scaled TcType))
-&gt; [Scaled ExpRhoType]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Scaled TcType]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681079970"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079970"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681079969"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079969"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Scaled TcType
forall a. TcType -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079970"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; Scaled TcType)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Scaled TcType)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-var">readExpType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079969"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079981"><span class="hs-identifier hs-var">more_arg_tys</span></a></span><span>
</span><span id="line-219"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079967"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079967"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-var">readExpType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079974"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-220"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079966"><span class="annot"><span class="annottext">unif_fun_ty :: TcType
</span><a href="#local-6989586621681079966"><span class="hs-identifier hs-var hs-var">unif_fun_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Scaled TcType] -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTys"><span class="hs-identifier hs-var">mkVisFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079972"><span class="hs-identifier hs-var">more_arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079967"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-221"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079964"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079964"><span class="hs-identifier hs-var">wrap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; UserTypeCtxt -&gt; TcType -&gt; ExpRhoType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubType"><span class="hs-identifier hs-var">tcSubType</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#AppOrigin"><span class="hs-identifier hs-var">AppOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681080072"><span class="hs-identifier hs-var">ctx</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079966"><span class="hs-identifier hs-var">unif_fun_ty</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079982"><span class="hs-identifier hs-var">fun_ty</span></a></span><span>
</span><span id="line-222"></span><span>                         </span><span class="hs-comment">-- Not a good origin at all :-(</span><span>
</span><span id="line-223"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, a) -&gt; TcM (HsWrapper, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079964"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681079973"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-224"></span><span>
</span><span id="line-225"></span><span>    </span><span class="hs-comment">------------</span><span>
</span><span id="line-226"></span><span>    </span><span class="annot"><a href="#local-6989586621681079985"><span class="hs-identifier hs-type">mk_ctxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpSigmaType"><span class="hs-identifier hs-type">ExpSigmaType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-227"></span><span>    </span><span id="local-6989586621681079985"><span class="annot"><span class="annottext">mk_ctxt :: [Scaled ExpRhoType] -&gt; TcType -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="#local-6989586621681079985"><span class="hs-identifier hs-var hs-var">mk_ctxt</span></a></span></span><span> </span><span id="local-6989586621681079961"><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079961"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span id="local-6989586621681079960"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079960"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span id="local-6989586621681079959"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079959"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-228"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079958"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079958"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079957"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079957"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcType -&gt; TcM (TidyEnv, TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079959"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled TcType] -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTys"><span class="hs-identifier hs-var">mkVisFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079955"><span class="hs-identifier hs-var">arg_tys'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079960"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-229"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079958"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcType -&gt; Int -&gt; SDoc
</span><a href="GHC.Tc.Utils.Unify.html#mk_fun_tys_msg"><span class="hs-identifier hs-var">mk_fun_tys_msg</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681080073"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079957"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681080071"><span class="hs-identifier hs-var">arity</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-230"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-231"></span><span>        </span><span id="local-6989586621681079955"><span class="annot"><span class="annottext">arg_tys' :: [Scaled TcType]
</span><a href="#local-6989586621681079955"><span class="hs-identifier hs-var hs-var">arg_tys'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Scaled ExpRhoType -&gt; Scaled TcType)
-&gt; [Scaled ExpRhoType] -&gt; [Scaled TcType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681079953"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079953"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span id="local-6989586621681079952"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079952"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Scaled TcType
forall a. TcType -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079953"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; ExpRhoType -&gt; TcType
</span><a href="GHC.Tc.Utils.TcMType.html#checkingExpType"><span class="hs-identifier hs-var">checkingExpType</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;matchExpectedFunTys&quot;</span></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079952"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled ExpRhoType] -&gt; [Scaled ExpRhoType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled ExpRhoType]
</span><a href="#local-6989586621681079961"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span>            </span><span class="hs-comment">-- this is safe b/c we're called from &quot;go&quot;</span><span>
</span><span id="line-233"></span><span>
</span><span id="line-234"></span><span class="hs-comment">-- Like 'matchExpectedFunTys', but used when you have an &quot;actual&quot; type,</span><span>
</span><span id="line-235"></span><span class="hs-comment">-- for example in function application</span><span>
</span><span id="line-236"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchActualFunTysRho"><span class="hs-identifier hs-type">matchActualFunTysRho</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>   </span><span class="hs-comment">-- See Note [Herald for matchExpectedFunTys]</span><span>
</span><span id="line-237"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-238"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- the thing with type TcSigmaType</span><span>
</span><span id="line-239"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-240"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>
</span><span id="line-241"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-242"></span><span class="hs-comment">-- If    matchActualFunTysRho n ty = (wrap, [t1,..,tn], res_ty)</span><span>
</span><span id="line-243"></span><span class="hs-comment">-- then  wrap : ty ~&gt; (t1 -&gt; ... -&gt; tn -&gt; res_ty)</span><span>
</span><span id="line-244"></span><span class="hs-comment">--       and res_ty is a RhoType</span><span>
</span><span id="line-245"></span><span class="hs-comment">-- NB: the returned type is top-instantiated; it's a RhoType</span><span>
</span><span id="line-246"></span><span id="matchActualFunTysRho"><span class="annot"><span class="annottext">matchActualFunTysRho :: SDoc
-&gt; CtOrigin
-&gt; Maybe (HsExpr GhcRn)
-&gt; Int
-&gt; TcType
-&gt; TcM (HsWrapper, [Scaled TcType], TcType)
</span><a href="GHC.Tc.Utils.Unify.html#matchActualFunTysRho"><span class="hs-identifier hs-var hs-var">matchActualFunTysRho</span></a></span></span><span> </span><span id="local-6989586621681079948"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079948"><span class="hs-identifier hs-var">herald</span></a></span></span><span> </span><span id="local-6989586621681079947"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079947"><span class="hs-identifier hs-var">ct_orig</span></a></span></span><span> </span><span id="local-6989586621681079946"><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079946"><span class="hs-identifier hs-var">mb_thing</span></a></span></span><span> </span><span id="local-6989586621681079945"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079945"><span class="hs-identifier hs-var">n_val_args_wanted</span></a></span></span><span> </span><span id="local-6989586621681079944"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079944"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span>
</span><span id="line-247"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
-&gt; [Scaled TcType]
-&gt; TcType
-&gt; TcM (HsWrapper, [Scaled TcType], TcType)
forall {t}.
(Eq t, Num t) =&gt;
t
-&gt; [Scaled TcType]
-&gt; TcType
-&gt; TcM (HsWrapper, [Scaled TcType], TcType)
</span><a href="#local-6989586621681079943"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079945"><span class="hs-identifier hs-var">n_val_args_wanted</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079944"><span class="hs-identifier hs-var">fun_ty</span></a></span><span>
</span><span id="line-248"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-249"></span><span>    </span><span id="local-6989586621681079943"><span class="annot"><span class="annottext">go :: t
-&gt; [Scaled TcType]
-&gt; TcType
-&gt; TcM (HsWrapper, [Scaled TcType], TcType)
</span><a href="#local-6989586621681079943"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">[Scaled TcType]
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681079931"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079931"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span>
</span><span id="line-250"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079930"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079930"><span class="hs-identifier hs-var">wrap</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079929"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079929"><span class="hs-identifier hs-var">rho</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TcType -&gt; TcM (HsWrapper, TcType)
</span><a href="GHC.Tc.Utils.Instantiate.html#topInstantiate"><span class="hs-identifier hs-var">topInstantiate</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079947"><span class="hs-identifier hs-var">ct_orig</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079931"><span class="hs-identifier hs-var">fun_ty</span></a></span><span>
</span><span id="line-251"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, [Scaled TcType], TcType)
-&gt; TcM (HsWrapper, [Scaled TcType], TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079930"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079929"><span class="hs-identifier hs-var">rho</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-252"></span><span>    </span><span class="annot"><a href="#local-6989586621681079943"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079927"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681079927"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079926"><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079926"><span class="hs-identifier hs-var">so_far</span></a></span></span><span> </span><span id="local-6989586621681079925"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079925"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span>
</span><span id="line-253"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079924"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079924"><span class="hs-identifier hs-var">wrap_fun1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079923"><span class="annot"><span class="annottext">Scaled TcType
</span><a href="#local-6989586621681079923"><span class="hs-identifier hs-var">arg_ty1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079922"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079922"><span class="hs-identifier hs-var">res_ty1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SDoc
-&gt; CtOrigin
-&gt; Maybe (HsExpr GhcRn)
-&gt; (Int, [Scaled TcType])
-&gt; TcType
-&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="GHC.Tc.Utils.Unify.html#matchActualFunTySigma"><span class="hs-identifier hs-var">matchActualFunTySigma</span></a></span><span>
</span><span id="line-254"></span><span>                                                 </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079948"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079947"><span class="hs-identifier hs-var">ct_orig</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079946"><span class="hs-identifier hs-var">mb_thing</span></a></span><span>
</span><span id="line-255"></span><span>                                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079945"><span class="hs-identifier hs-var">n_val_args_wanted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079926"><span class="hs-identifier hs-var">so_far</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-256"></span><span>                                                 </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079925"><span class="hs-identifier hs-var">fun_ty</span></a></span><span>
</span><span id="line-257"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079921"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079921"><span class="hs-identifier hs-var">wrap_res</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079920"><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079920"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079919"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079919"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">t
-&gt; [Scaled TcType]
-&gt; TcType
-&gt; TcM (HsWrapper, [Scaled TcType], TcType)
</span><a href="#local-6989586621681079943"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681079927"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Scaled TcType
</span><a href="#local-6989586621681079923"><span class="hs-identifier hs-var">arg_ty1</span></a></span><span class="annot"><span class="annottext">Scaled TcType -&gt; [Scaled TcType] -&gt; [Scaled TcType]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079926"><span class="hs-identifier hs-var">so_far</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079922"><span class="hs-identifier hs-var">res_ty1</span></a></span><span>
</span><span id="line-258"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079918"><span class="annot"><span class="annottext">wrap_fun2 :: HsWrapper
</span><a href="#local-6989586621681079918"><span class="hs-identifier hs-var hs-var">wrap_fun2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper
-&gt; HsWrapper -&gt; Scaled TcType -&gt; TcType -&gt; SDoc -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpFun"><span class="hs-identifier hs-var">mkWpFun</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079921"><span class="hs-identifier hs-var">wrap_res</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled TcType
</span><a href="#local-6989586621681079923"><span class="hs-identifier hs-var">arg_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079919"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079917"><span class="hs-identifier hs-var">doc</span></a></span><span>
</span><span id="line-259"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, [Scaled TcType], TcType)
-&gt; TcM (HsWrapper, [Scaled TcType], TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079918"><span class="hs-identifier hs-var">wrap_fun2</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079924"><span class="hs-identifier hs-var">wrap_fun1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Scaled TcType
</span><a href="#local-6989586621681079923"><span class="hs-identifier hs-var">arg_ty1</span></a></span><span class="annot"><span class="annottext">Scaled TcType -&gt; [Scaled TcType] -&gt; [Scaled TcType]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079920"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079919"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-260"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-261"></span><span>        </span><span id="local-6989586621681079917"><span class="annot"><span class="annottext">doc :: SDoc
</span><a href="#local-6989586621681079917"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;When inferring the argument type of a function with type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-262"></span><span>              </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079925"><span class="hs-identifier hs-var">fun_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span class="hs-comment">-- | matchActualFunTySigm does looks for just one function arrow</span><span>
</span><span id="line-265"></span><span class="hs-comment">--   returning an uninstantiated sigma-type</span><span>
</span><span id="line-266"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchActualFunTySigma"><span class="hs-identifier hs-type">matchActualFunTySigma</span></a></span><span>
</span><span id="line-267"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-comment">-- See Note [Herald for matchExpectedFunTys]</span><span>
</span><span id="line-268"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-269"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- The thing with type TcSigmaType</span><span>
</span><span id="line-270"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Total number of value args in the call, and</span><span>
</span><span id="line-271"></span><span>                            </span><span class="hs-comment">-- types of values args to which function has</span><span>
</span><span id="line-272"></span><span>                            </span><span class="hs-comment">--   been applied already (reversed)</span><span>
</span><span id="line-273"></span><span>                            </span><span class="hs-comment">-- Both are used only for error messages)</span><span>
</span><span id="line-274"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>            </span><span class="hs-comment">-- Type to analyse</span><span>
</span><span id="line-275"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span class="hs-comment">-- See Note [matchActualFunTys error handling] for all these arguments</span><span>
</span><span id="line-277"></span><span>
</span><span id="line-278"></span><span class="hs-comment">-- If   (wrap, arg_ty, res_ty) = matchActualFunTySigma ... fun_ty</span><span>
</span><span id="line-279"></span><span class="hs-comment">-- then wrap :: fun_ty ~&gt; (arg_ty -&gt; res_ty)</span><span>
</span><span id="line-280"></span><span class="hs-comment">-- and NB: res_ty is an (uninstantiated) SigmaType</span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span id="matchActualFunTySigma"><span class="annot"><span class="annottext">matchActualFunTySigma :: SDoc
-&gt; CtOrigin
-&gt; Maybe (HsExpr GhcRn)
-&gt; (Int, [Scaled TcType])
-&gt; TcType
-&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="GHC.Tc.Utils.Unify.html#matchActualFunTySigma"><span class="hs-identifier hs-var hs-var">matchActualFunTySigma</span></a></span></span><span> </span><span id="local-6989586621681079915"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079915"><span class="hs-identifier hs-var">herald</span></a></span></span><span> </span><span id="local-6989586621681079914"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079914"><span class="hs-identifier hs-var">ct_orig</span></a></span></span><span> </span><span id="local-6989586621681079913"><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079913"><span class="hs-identifier hs-var">mb_thing</span></a></span></span><span> </span><span id="local-6989586621681079912"><span class="annot"><span class="annottext">(Int, [Scaled TcType])
</span><a href="#local-6989586621681079912"><span class="hs-identifier hs-var">err_info</span></a></span></span><span> </span><span id="local-6989586621681079911"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079911"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span>
</span><span id="line-283"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079911"><span class="hs-identifier hs-var">fun_ty</span></a></span><span>
</span><span id="line-284"></span><span class="hs-comment">-- Does not allocate unnecessary meta variables: if the input already is</span><span>
</span><span id="line-285"></span><span class="hs-comment">-- a function, we just take it apart.  Not only is this efficient,</span><span>
</span><span id="line-286"></span><span class="hs-comment">-- it's important for higher rank: the argument might be of form</span><span>
</span><span id="line-287"></span><span class="hs-comment">--              (forall a. ty) -&gt; other</span><span>
</span><span id="line-288"></span><span class="hs-comment">-- If allocated (fresh-meta-var1 -&gt; fresh-meta-var2) and unified, we'd</span><span>
</span><span id="line-289"></span><span class="hs-comment">-- hide the forall inside a meta-variable</span><span>
</span><span id="line-290"></span><span>
</span><span id="line-291"></span><span class="hs-comment">-- (*) Sometimes it's necessary to call matchActualFunTys with only part</span><span>
</span><span id="line-292"></span><span class="hs-comment">-- (that is, to the right of some arrows) of the type of the function in</span><span>
</span><span id="line-293"></span><span class="hs-comment">-- question. (See GHC.Tc.Gen.Expr.tcArgs.) This argument is the reversed list of</span><span>
</span><span id="line-294"></span><span class="hs-comment">-- arguments already seen (that is, not part of the TcSigmaType passed</span><span>
</span><span id="line-295"></span><span class="hs-comment">-- in elsewhere).</span><span>
</span><span id="line-296"></span><span>
</span><span id="line-297"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-298"></span><span>    </span><span class="annot"><a href="#local-6989586621681079910"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>   </span><span class="hs-comment">-- The remainder of the type as we're processing</span><span>
</span><span id="line-299"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-300"></span><span>    </span><span id="local-6989586621681079910"><span class="annot"><span class="annottext">go :: TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079910"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681079909"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079909"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079908"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079908"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079909"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079908"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-301"></span><span>
</span><span id="line-302"></span><span>    </span><span class="annot"><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079907"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079907"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-303"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079906"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079905"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-304"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079904"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079904"><span class="hs-identifier hs-var">wrap1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079903"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079903"><span class="hs-identifier hs-var">rho</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TcType -&gt; TcM (HsWrapper, TcType)
</span><a href="GHC.Tc.Utils.Instantiate.html#topInstantiate"><span class="hs-identifier hs-var">topInstantiate</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079914"><span class="hs-identifier hs-var">ct_orig</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079907"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-305"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079902"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079902"><span class="hs-identifier hs-var">wrap2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079901"><span class="annot"><span class="annottext">Scaled TcType
</span><a href="#local-6989586621681079901"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079900"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079900"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079903"><span class="hs-identifier hs-var">rho</span></a></span><span>
</span><span id="line-306"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, Scaled TcType, TcType)
-&gt; TcM (HsWrapper, Scaled TcType, TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079902"><span class="hs-identifier hs-var">wrap2</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079904"><span class="hs-identifier hs-var">wrap1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Scaled TcType
</span><a href="#local-6989586621681079901"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079900"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-307"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-308"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681079906"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079906"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079905"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079905"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([TcTyVar], ThetaType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitSigmaTy"><span class="hs-identifier hs-var">tcSplitSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079907"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span>    </span><span class="annot"><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_af :: TcType -&gt; AnonArgFlag
</span><a href="GHC.Core.TyCo.Rep.html#ft_af"><span class="hs-identifier hs-var">ft_af</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079899"><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681079899"><span class="hs-identifier hs-var">af</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_mult :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079898"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079898"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_arg :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079897"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079897"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079896"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079896"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-311"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">af</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">VisArg</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span>        </span><span class="annot"><span class="annottext">(HsWrapper, Scaled TcType, TcType)
-&gt; TcM (HsWrapper, Scaled TcType, TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Scaled TcType
forall a. TcType -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079898"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079897"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079896"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>
</span><span id="line-314"></span><span>    </span><span class="annot"><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079895"><span class="annot"><span class="annottext">ty :: TcType
</span><a href="#local-6989586621681079895"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079894"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079894"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-315"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079894"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-316"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079893"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079893"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var">readMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079894"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-317"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079893"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-318"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681079892"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079892"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079892"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-319"></span><span>               </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079891"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079895"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-320"></span><span>
</span><span id="line-321"></span><span>       </span><span class="hs-comment">-- In all other cases we bale out into ordinary unification</span><span>
</span><span id="line-322"></span><span>       </span><span class="hs-comment">-- However unlike the meta-tyvar case, we are sure that the</span><span>
</span><span id="line-323"></span><span>       </span><span class="hs-comment">-- number of arguments doesn't match arity of the original</span><span>
</span><span id="line-324"></span><span>       </span><span class="hs-comment">-- type, so we can add a bit more context to the error message</span><span>
</span><span id="line-325"></span><span>       </span><span class="hs-comment">-- (cf #7869).</span><span>
</span><span id="line-326"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-327"></span><span>       </span><span class="hs-comment">-- It is not always an error, because specialized type may have</span><span>
</span><span id="line-328"></span><span>       </span><span class="hs-comment">-- different arity, for example:</span><span>
</span><span id="line-329"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-330"></span><span>       </span><span class="hs-comment">-- &gt; f1 = f2 'a'</span><span>
</span><span id="line-331"></span><span>       </span><span class="hs-comment">-- &gt; f2 :: Monad m =&gt; m Bool</span><span>
</span><span id="line-332"></span><span>       </span><span class="hs-comment">-- &gt; f2 = undefined</span><span>
</span><span id="line-333"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-334"></span><span>       </span><span class="hs-comment">-- But in that case we add specialized type into error context</span><span>
</span><span id="line-335"></span><span>       </span><span class="hs-comment">-- anyway, because it may be useful. See also #9605.</span><span>
</span><span id="line-336"></span><span>    </span><span class="annot"><a href="#local-6989586621681079910"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079890"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079890"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv -&gt; TcM (TidyEnv, SDoc))
-&gt; TcM (HsWrapper, Scaled TcType, TcType)
-&gt; TcM (HsWrapper, Scaled TcType, TcType)
forall a. (TidyEnv -&gt; TcM (TidyEnv, SDoc)) -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxtM"><span class="hs-identifier hs-var">addErrCtxtM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="#local-6989586621681079889"><span class="hs-identifier hs-var">mk_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079890"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079891"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079890"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-337"></span><span>
</span><span id="line-338"></span><span>    </span><span class="hs-comment">------------</span><span>
</span><span id="line-339"></span><span>    </span><span id="local-6989586621681079891"><span class="annot"><span class="annottext">defer :: TcType -&gt; TcM (HsWrapper, Scaled TcType, TcType)
</span><a href="#local-6989586621681079891"><span class="hs-identifier hs-var hs-var">defer</span></a></span></span><span> </span><span id="local-6989586621681079883"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079883"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span>
</span><span id="line-340"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079882"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079882"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenFlexiTyVarTy"><span class="hs-identifier hs-var">newOpenFlexiTyVarTy</span></a></span><span>
</span><span id="line-341"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079880"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079880"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenFlexiTyVarTy"><span class="hs-identifier hs-var">newOpenFlexiTyVarTy</span></a></span><span>
</span><span id="line-342"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079879"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079879"><span class="hs-identifier hs-var">mult</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="GHC.Builtin.Types.html#multiplicityTy"><span class="hs-identifier hs-var">multiplicityTy</span></a></span><span>
</span><span id="line-343"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079878"><span class="annot"><span class="annottext">unif_fun_ty :: TcType
</span><a href="#local-6989586621681079878"><span class="hs-identifier hs-var hs-var">unif_fun_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTy"><span class="hs-identifier hs-var">mkVisFunTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079879"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079882"><span class="hs-identifier hs-var">arg_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079880"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-344"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079876"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079876"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079913"><span class="hs-identifier hs-var">mb_thing</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079883"><span class="hs-identifier hs-var">fun_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079878"><span class="hs-identifier hs-var">unif_fun_ty</span></a></span><span>
</span><span id="line-345"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, Scaled TcType, TcType)
-&gt; TcM (HsWrapper, Scaled TcType, TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpCastN"><span class="hs-identifier hs-var">mkWpCastN</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079876"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; Scaled TcType
forall a. TcType -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079879"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079882"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079880"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-346"></span><span>
</span><span id="line-347"></span><span>    </span><span class="hs-comment">------------</span><span>
</span><span id="line-348"></span><span>    </span><span class="annot"><a href="#local-6989586621681079889"><span class="hs-identifier hs-type">mk_ctxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-349"></span><span>    </span><span id="local-6989586621681079889"><span class="annot"><span class="annottext">mk_ctxt :: TcType -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="#local-6989586621681079889"><span class="hs-identifier hs-var hs-var">mk_ctxt</span></a></span></span><span> </span><span id="local-6989586621681079874"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079874"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span id="local-6989586621681079873"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079873"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-350"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079872"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079872"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079871"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079871"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcType -&gt; TcM (TidyEnv, TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079873"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcM (TidyEnv, TcType))
-&gt; TcType -&gt; TcM (TidyEnv, TcType)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-351"></span><span>                           </span><span class="annot"><span class="annottext">[Scaled TcType] -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTys"><span class="hs-identifier hs-var">mkVisFunTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled TcType] -&gt; [Scaled TcType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079870"><span class="hs-identifier hs-var">arg_tys_so_far</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079874"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-352"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079872"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcType -&gt; Int -&gt; SDoc
</span><a href="GHC.Tc.Utils.Unify.html#mk_fun_tys_msg"><span class="hs-identifier hs-var">mk_fun_tys_msg</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079915"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079871"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079869"><span class="hs-identifier hs-var">n_val_args_in_call</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-353"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681079869"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079869"><span class="hs-identifier hs-var">n_val_args_in_call</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079870"><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079870"><span class="hs-identifier hs-var">arg_tys_so_far</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, [Scaled TcType])
</span><a href="#local-6989586621681079912"><span class="hs-identifier hs-var">err_info</span></a></span><span>
</span><span id="line-354"></span><span>
</span><span id="line-355"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#mk_fun_tys_msg"><span class="hs-identifier hs-type">mk_fun_tys_msg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-356"></span><span id="mk_fun_tys_msg"><span class="annot"><span class="annottext">mk_fun_tys_msg :: SDoc -&gt; TcType -&gt; Int -&gt; SDoc
</span><a href="GHC.Tc.Utils.Unify.html#mk_fun_tys_msg"><span class="hs-identifier hs-var hs-var">mk_fun_tys_msg</span></a></span></span><span> </span><span id="local-6989586621681079868"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079868"><span class="hs-identifier hs-var">herald</span></a></span></span><span> </span><span id="local-6989586621681079867"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079867"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681079866"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079866"><span class="hs-identifier hs-var">n_args_in_call</span></a></span></span><span>
</span><span id="line-357"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079866"><span class="hs-identifier hs-var">n_args_in_call</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079864"><span class="hs-identifier hs-var">n_fun_args</span></a></span><span>  </span><span class="hs-comment">-- Enough args, in the end</span><span>
</span><span id="line-358"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;In the result of a function call&quot;</span></span><span>
</span><span id="line-359"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-360"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079868"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#speakNOf"><span class="hs-identifier hs-var">speakNOf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079866"><span class="hs-identifier hs-var">n_args_in_call</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;value argument&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#comma"><span class="hs-identifier hs-var">comma</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>       </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;but its type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprType"><span class="hs-identifier hs-var">pprType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079867"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-362"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079864"><span class="hs-identifier hs-var">n_fun_args</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;has none&quot;</span></span><span>
</span><span id="line-363"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;has only&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#speakN"><span class="hs-identifier hs-var">speakN</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079864"><span class="hs-identifier hs-var">n_fun_args</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-364"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-365"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681079856"><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079856"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([Scaled TcType], TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTys"><span class="hs-identifier hs-var">tcSplitFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079867"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-366"></span><span>    </span><span id="local-6989586621681079864"><span class="annot"><span class="annottext">n_fun_args :: Int
</span><a href="#local-6989586621681079864"><span class="hs-identifier hs-var hs-var">n_fun_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Scaled TcType] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled TcType]
</span><a href="#local-6989586621681079856"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span class="hs-comment">{- Note [matchActualFunTys error handling]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
matchActualFunTysPart is made much more complicated by the
desire to produce good error messages. Consider the application
    f @Int x y
In GHC.Tc.Gen.Expr.tcArgs we deal with visible type arguments,
and then call matchActualFunTysPart for each individual value
argument. It, in turn, must instantiate any type/dictionary args,
before looking for an arrow type.

But if it doesn't find an arrow type, it wants to generate a message
like &quot;f is applied to two arguments but its type only has one&quot;.
To do that, it needs to konw about the args that tcArgs has already
munched up -- hence passing in n_val_args_in_call and arg_tys_so_far;
and hence also the accumulating so_far arg to 'go'.

This allows us (in mk_ctxt) to construct f's /instantiated/ type,
with just the values-arg arrows, which is what we really want
in the error message.

Ugh!
-}</span><span>
</span><span id="line-390"></span><span>
</span><span id="line-391"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-392"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedListTy"><span class="hs-identifier hs-type">matchExpectedListTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercionN"><span class="hs-identifier hs-type">TcCoercionN</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span class="hs-comment">-- Special case for lists</span><span>
</span><span id="line-394"></span><span id="matchExpectedListTy"><span class="annot"><span class="annottext">matchExpectedListTy :: TcType -&gt; TcM (Coercion, TcType)
</span><a href="GHC.Tc.Utils.Unify.html#matchExpectedListTy"><span class="hs-identifier hs-var hs-var">matchExpectedListTy</span></a></span></span><span> </span><span id="local-6989586621681079851"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079851"><span class="hs-identifier hs-var">exp_ty</span></a></span></span><span>
</span><span id="line-395"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079850"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079850"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621681079849"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079849"><span class="hs-identifier hs-var">elt_ty</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TcType -&gt; TcM (Coercion, ThetaType)
</span><a href="GHC.Tc.Utils.Unify.html#matchExpectedTyConApp"><span class="hs-identifier hs-var">matchExpectedTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#listTyCon"><span class="hs-identifier hs-var">listTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079851"><span class="hs-identifier hs-var">exp_ty</span></a></span><span>
</span><span id="line-396"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Coercion, TcType) -&gt; TcM (Coercion, TcType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079850"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079849"><span class="hs-identifier hs-var">elt_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-397"></span><span>
</span><span id="line-398"></span><span class="hs-comment">---------------------</span><span>
</span><span id="line-399"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedTyConApp"><span class="hs-identifier hs-type">matchExpectedTyConApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>                </span><span class="hs-comment">-- T :: forall kv1 ... kvm. k1 -&gt; ... -&gt; kn -&gt; *</span><span>
</span><span id="line-400"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span>            </span><span class="hs-comment">-- orig_ty</span><span>
</span><span id="line-401"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercionN"><span class="hs-identifier hs-type">TcCoercionN</span></a></span><span class="hs-special">,</span><span>    </span><span class="hs-comment">-- T k1 k2 k3 a b c ~N orig_ty</span><span>
</span><span id="line-402"></span><span>                              </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Element types, k1 k2 k3 a b c</span><span>
</span><span id="line-403"></span><span>
</span><span id="line-404"></span><span class="hs-comment">-- It's used for wired-in tycons, so we call checkWiredInTyCon</span><span>
</span><span id="line-405"></span><span class="hs-comment">-- Precondition: never called with FunTyCon</span><span>
</span><span id="line-406"></span><span class="hs-comment">-- Precondition: input type :: *</span><span>
</span><span id="line-407"></span><span class="hs-comment">-- Postcondition: (T k1 k2 k3 a b c) is well-kinded</span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span id="matchExpectedTyConApp"><span class="annot"><span class="annottext">matchExpectedTyConApp :: TyCon -&gt; TcType -&gt; TcM (Coercion, ThetaType)
</span><a href="GHC.Tc.Utils.Unify.html#matchExpectedTyConApp"><span class="hs-identifier hs-var hs-var">matchExpectedTyConApp</span></a></span></span><span> </span><span id="local-6989586621681079847"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079847"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681079846"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079846"><span class="hs-identifier hs-var">orig_ty</span></a></span></span><span>
</span><span id="line-410"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span class="hs-identifier">not</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">isFunTyCon</span><span> </span><span class="hs-identifier">tc</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">go</span><span> </span><span class="hs-identifier">orig_ty</span><span>
</span><span id="line-411"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-412"></span><span>    </span><span id="local-6989586621681079844"><span class="annot"><span class="annottext">go :: TcType -&gt; TcM (Coercion, ThetaType)
</span><a href="#local-6989586621681079844"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681079840"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079840"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-413"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079839"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079839"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079840"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-414"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (Coercion, ThetaType)
</span><a href="#local-6989586621681079844"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079839"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-415"></span><span>
</span><span id="line-416"></span><span>    </span><span class="annot"><a href="#local-6989586621681079844"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079838"><span class="annot"><span class="annottext">ty :: TcType
</span><a href="#local-6989586621681079838"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079836"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079836"><span class="hs-identifier hs-var">tycon</span></a></span></span><span> </span><span id="local-6989586621681079835"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079835"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-417"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079847"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079836"><span class="hs-identifier hs-var">tycon</span></a></span><span>  </span><span class="hs-comment">-- Common case</span><span>
</span><span id="line-418"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion, ThetaType) -&gt; TcM (Coercion, ThetaType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcNomReflCo"><span class="hs-identifier hs-var">mkTcNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079838"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079835"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-419"></span><span>
</span><span id="line-420"></span><span>    </span><span class="annot"><a href="#local-6989586621681079844"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079833"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079833"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-421"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079833"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-422"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079832"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079832"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var">readMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079833"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-423"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079832"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-424"></span><span>                </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681079831"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079831"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (Coercion, ThetaType)
</span><a href="#local-6989586621681079844"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079831"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-425"></span><span>                </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, ThetaType)
</span><a href="#local-6989586621681079830"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span>    </span><span class="annot"><a href="#local-6989586621681079844"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, ThetaType)
</span><a href="#local-6989586621681079830"><span class="hs-identifier hs-var">defer</span></a></span><span>
</span><span id="line-428"></span><span>
</span><span id="line-429"></span><span>    </span><span class="hs-comment">-- If the common case does not occur, instantiate a template</span><span>
</span><span id="line-430"></span><span>    </span><span class="hs-comment">-- T k1 .. kn t1 .. tm, and unify with the original type</span><span>
</span><span id="line-431"></span><span>    </span><span class="hs-comment">-- Doing it this way ensures that the types we return are</span><span>
</span><span id="line-432"></span><span>    </span><span class="hs-comment">-- kind-compatible with T.  For example, suppose we have</span><span>
</span><span id="line-433"></span><span>    </span><span class="hs-comment">--       matchExpectedTyConApp T (f Maybe)</span><span>
</span><span id="line-434"></span><span>    </span><span class="hs-comment">-- where data T a = MkT a</span><span>
</span><span id="line-435"></span><span>    </span><span class="hs-comment">-- Then we don't want to instantiate T's data constructors with</span><span>
</span><span id="line-436"></span><span>    </span><span class="hs-comment">--    (a::*) ~ Maybe</span><span>
</span><span id="line-437"></span><span>    </span><span class="hs-comment">-- because that'll make types that are utterly ill-kinded.</span><span>
</span><span id="line-438"></span><span>    </span><span class="hs-comment">-- This happened in #7368</span><span>
</span><span id="line-439"></span><span>    </span><span id="local-6989586621681079830"><span class="annot"><span class="annottext">defer :: TcM (Coercion, ThetaType)
</span><a href="#local-6989586621681079830"><span class="hs-identifier hs-var hs-var">defer</span></a></span></span><span>
</span><span id="line-440"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079821"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079821"><span class="hs-identifier hs-var">arg_tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; TcM (TCvSubst, [TcTyVar])
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVars"><span class="hs-identifier hs-var">newMetaTyVars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [TcTyVar]
</span><a href="GHC.Core.TyCon.html#tyConTyVars"><span class="hs-identifier hs-var hs-var">tyConTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079847"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-441"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;matchExpectedTyConApp&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079847"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [TcTyVar]
</span><a href="GHC.Core.TyCon.html#tyConTyVars"><span class="hs-identifier hs-var hs-var">tyConTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079847"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079821"><span class="hs-identifier hs-var">arg_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-442"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079816"><span class="annot"><span class="annottext">args :: ThetaType
</span><a href="#local-6989586621681079816"><span class="hs-identifier hs-var hs-var">args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079821"><span class="hs-identifier hs-var">arg_tvs</span></a></span><span>
</span><span id="line-443"></span><span>                 </span><span id="local-6989586621681079814"><span class="annot"><span class="annottext">tc_template :: TcType
</span><a href="#local-6989586621681079814"><span class="hs-identifier hs-var hs-var">tc_template</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; ThetaType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079847"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079816"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-444"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079812"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079812"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079814"><span class="hs-identifier hs-var">tc_template</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079846"><span class="hs-identifier hs-var">orig_ty</span></a></span><span>
</span><span id="line-445"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Coercion, ThetaType) -&gt; TcM (Coercion, ThetaType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079812"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079816"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-446"></span><span>
</span><span id="line-447"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-448"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedAppTy"><span class="hs-identifier hs-type">matchExpectedAppTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span>                         </span><span class="hs-comment">-- orig_ty</span><span>
</span><span id="line-449"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span class="hs-special">,</span><span>                   </span><span class="hs-comment">-- m a ~N orig_ty</span><span>
</span><span id="line-450"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Returns m, a</span><span>
</span><span id="line-451"></span><span class="hs-comment">-- If the incoming type is a mutable type variable of kind k, then</span><span>
</span><span id="line-452"></span><span class="hs-comment">-- matchExpectedAppTy returns a new type variable (m: * -&gt; k); note the *.</span><span>
</span><span id="line-453"></span><span>
</span><span id="line-454"></span><span id="matchExpectedAppTy"><span class="annot"><span class="annottext">matchExpectedAppTy :: TcType -&gt; TcM (Coercion, (TcType, TcType))
</span><a href="GHC.Tc.Utils.Unify.html#matchExpectedAppTy"><span class="hs-identifier hs-var hs-var">matchExpectedAppTy</span></a></span></span><span> </span><span id="local-6989586621681079810"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079810"><span class="hs-identifier hs-var">orig_ty</span></a></span></span><span>
</span><span id="line-455"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (Coercion, (TcType, TcType))
</span><a href="#local-6989586621681079809"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079810"><span class="hs-identifier hs-var">orig_ty</span></a></span><span>
</span><span id="line-456"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-457"></span><span>    </span><span id="local-6989586621681079809"><span class="annot"><span class="annottext">go :: TcType -&gt; TcM (Coercion, (TcType, TcType))
</span><a href="#local-6989586621681079809"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681079806"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079806"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-458"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079805"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079805"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079806"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (Coercion, (TcType, TcType))
</span><a href="#local-6989586621681079809"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079805"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-459"></span><span>
</span><span id="line-460"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079804"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079804"><span class="hs-identifier hs-var">fun_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079803"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079803"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitAppTy_maybe"><span class="hs-identifier hs-var">tcSplitAppTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079806"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-461"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion, (TcType, TcType)) -&gt; TcM (Coercion, (TcType, TcType))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcNomReflCo"><span class="hs-identifier hs-var">mkTcNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079810"><span class="hs-identifier hs-var">orig_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079804"><span class="hs-identifier hs-var">fun_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079803"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-462"></span><span>
</span><span id="line-463"></span><span>    </span><span class="annot"><a href="#local-6989586621681079809"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079801"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079801"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-464"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079801"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-465"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079800"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079800"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var">readMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079801"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-466"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079800"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-467"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681079799"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079799"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (Coercion, (TcType, TcType))
</span><a href="#local-6989586621681079809"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079799"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-468"></span><span>               </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, (TcType, TcType))
</span><a href="#local-6989586621681079798"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-469"></span><span>
</span><span id="line-470"></span><span>    </span><span class="annot"><a href="#local-6989586621681079809"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, (TcType, TcType))
</span><a href="#local-6989586621681079798"><span class="hs-identifier hs-var">defer</span></a></span><span>
</span><span id="line-471"></span><span>
</span><span id="line-472"></span><span>    </span><span class="hs-comment">-- Defer splitting by generating an equality constraint</span><span>
</span><span id="line-473"></span><span>    </span><span id="local-6989586621681079798"><span class="annot"><span class="annottext">defer :: TcM (Coercion, (TcType, TcType))
</span><a href="#local-6989586621681079798"><span class="hs-identifier hs-var hs-var">defer</span></a></span></span><span>
</span><span id="line-474"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079793"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079793"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079792"><span class="hs-identifier hs-var">kind1</span></a></span><span>
</span><span id="line-475"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079791"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079791"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079790"><span class="hs-identifier hs-var">kind2</span></a></span><span>
</span><span id="line-476"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079789"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079789"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#mkAppTy"><span class="hs-identifier hs-var">mkAppTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079793"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079791"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079810"><span class="hs-identifier hs-var">orig_ty</span></a></span><span>
</span><span id="line-477"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Coercion, (TcType, TcType)) -&gt; TcM (Coercion, (TcType, TcType))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079789"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079793"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079791"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-478"></span><span>
</span><span id="line-479"></span><span>    </span><span id="local-6989586621681079786"><span class="annot"><span class="annottext">orig_kind :: TcType
</span><a href="#local-6989586621681079786"><span class="hs-identifier hs-var hs-var">orig_kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079810"><span class="hs-identifier hs-var">orig_ty</span></a></span><span>
</span><span id="line-480"></span><span>    </span><span id="local-6989586621681079792"><span class="annot"><span class="annottext">kind1 :: TcType
</span><a href="#local-6989586621681079792"><span class="hs-identifier hs-var hs-var">kind1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTyMany"><span class="hs-identifier hs-var">mkVisFunTyMany</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079786"><span class="hs-identifier hs-var">orig_kind</span></a></span><span>
</span><span id="line-481"></span><span>    </span><span id="local-6989586621681079790"><span class="annot"><span class="annottext">kind2 :: TcType
</span><a href="#local-6989586621681079790"><span class="hs-identifier hs-var hs-var">kind2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span>    </span><span class="hs-comment">-- m :: * -&gt; k</span><span>
</span><span id="line-482"></span><span>                              </span><span class="hs-comment">-- arg type :: *</span><span>
</span><span id="line-483"></span><span>
</span><span id="line-484"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Subsumption checking
*                                                                      *
************************************************************************

Note [Subsumption checking: tcSubType]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All the tcSubType calls have the form
                tcSubType actual_ty expected_ty
which checks
                actual_ty &lt;= expected_ty

That is, that a value of type actual_ty is acceptable in
a place expecting a value of type expected_ty.  I.e. that

    actual ty   is more polymorphic than   expected_ty

It returns a wrapper function
        co_fn :: actual_ty ~ expected_ty
which takes an HsExpr of type actual_ty into one of type
expected_ty.
-}</span><span>
</span><span id="line-508"></span><span>
</span><span id="line-509"></span><span>
</span><span id="line-510"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-511"></span><span class="hs-comment">-- tcWrapResult needs both un-type-checked (for origins and error messages)</span><span>
</span><span id="line-512"></span><span class="hs-comment">-- and type-checked (for wrapping) expressions</span><span>
</span><span id="line-513"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcWrapResult"><span class="hs-identifier hs-type">tcWrapResult</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>
</span><span id="line-514"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-515"></span><span id="tcWrapResult"><span class="annot"><span class="annottext">tcWrapResult :: HsExpr GhcRn
-&gt; HsExpr GhcTc -&gt; TcType -&gt; ExpRhoType -&gt; TcM (HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Unify.html#tcWrapResult"><span class="hs-identifier hs-var hs-var">tcWrapResult</span></a></span></span><span> </span><span id="local-6989586621681079782"><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681079782"><span class="hs-identifier hs-var">rn_expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; HsExpr GhcRn
-&gt; HsExpr GhcTc
-&gt; TcType
-&gt; ExpRhoType
-&gt; TcM (HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Unify.html#tcWrapResultO"><span class="hs-identifier hs-var">tcWrapResultO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#exprCtOrigin"><span class="hs-identifier hs-var">exprCtOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681079782"><span class="hs-identifier hs-var">rn_expr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681079782"><span class="hs-identifier hs-var">rn_expr</span></a></span><span>
</span><span id="line-516"></span><span>
</span><span id="line-517"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcWrapResultO"><span class="hs-identifier hs-type">tcWrapResultO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>
</span><span id="line-518"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-519"></span><span id="tcWrapResultO"><span class="annot"><span class="annottext">tcWrapResultO :: CtOrigin
-&gt; HsExpr GhcRn
-&gt; HsExpr GhcTc
-&gt; TcType
-&gt; ExpRhoType
-&gt; TcM (HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Unify.html#tcWrapResultO"><span class="hs-identifier hs-var hs-var">tcWrapResultO</span></a></span></span><span> </span><span id="local-6989586621681079780"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079780"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681079779"><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681079779"><span class="hs-identifier hs-var">rn_expr</span></a></span></span><span> </span><span id="local-6989586621681079778"><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681079778"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621681079777"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079777"><span class="hs-identifier hs-var">actual_ty</span></a></span></span><span> </span><span id="local-6989586621681079776"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079776"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-520"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcWrapResult&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Actual:  &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079777"><span class="hs-identifier hs-var">actual_ty</span></a></span><span>
</span><span id="line-521"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Expected:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079776"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-522"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079774"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079774"><span class="hs-identifier hs-var">wrap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; UserTypeCtxt
-&gt; Maybe (HsExpr GhcRn)
-&gt; TcType
-&gt; ExpRhoType
-&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubTypeNC"><span class="hs-identifier hs-var">tcSubTypeNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079780"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#GenSigCtxt"><span class="hs-identifier hs-var">GenSigCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; Maybe (HsExpr GhcRn)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681079779"><span class="hs-identifier hs-var">rn_expr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079777"><span class="hs-identifier hs-var">actual_ty</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079776"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-523"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc -&gt; TcM (HsExpr GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper -&gt; HsExpr GhcTc -&gt; HsExpr GhcTc
</span><a href="GHC.Hs.Utils.html#mkHsWrap"><span class="hs-identifier hs-var">mkHsWrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079774"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681079778"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-524"></span><span>
</span><span id="line-525"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcWrapResultMono"><span class="hs-identifier hs-type">tcWrapResultMono</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span>
</span><span id="line-526"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span>   </span><span class="hs-comment">-- Actual -- a rho-type not a sigma-type</span><span>
</span><span id="line-527"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>  </span><span class="hs-comment">-- Expected</span><span>
</span><span id="line-528"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-529"></span><span class="hs-comment">-- A version of tcWrapResult to use when the actual type is a</span><span>
</span><span id="line-530"></span><span class="hs-comment">-- rho-type, so nothing to instantiate; just go straight to unify.</span><span>
</span><span id="line-531"></span><span class="hs-comment">-- It means we don't need to pass in a CtOrigin</span><span>
</span><span id="line-532"></span><span id="tcWrapResultMono"><span class="annot"><span class="annottext">tcWrapResultMono :: HsExpr GhcRn
-&gt; HsExpr GhcTc -&gt; TcType -&gt; ExpRhoType -&gt; TcM (HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Unify.html#tcWrapResultMono"><span class="hs-identifier hs-var hs-var">tcWrapResultMono</span></a></span></span><span> </span><span id="local-6989586621681079770"><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681079770"><span class="hs-identifier hs-var">rn_expr</span></a></span></span><span> </span><span id="local-6989586621681079769"><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681079769"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621681079768"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079768"><span class="hs-identifier hs-var">act_ty</span></a></span></span><span> </span><span id="local-6989586621681079767"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079767"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-533"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isRhoTy</span><span> </span><span class="hs-identifier">act_ty</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">act_ty</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">rn_expr</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-534"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079764"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079764"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079767"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-535"></span><span>                  </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Infer"><span class="hs-identifier hs-type">Infer</span></a></span><span> </span><span id="local-6989586621681079762"><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681079762"><span class="hs-identifier hs-var">inf_res</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; InferResult -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#fillInferResult"><span class="hs-identifier hs-var">fillInferResult</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079768"><span class="hs-identifier hs-var">act_ty</span></a></span><span> </span><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681079762"><span class="hs-identifier hs-var">inf_res</span></a></span><span>
</span><span id="line-536"></span><span>                  </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681079760"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079760"><span class="hs-identifier hs-var">exp_ty</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; Maybe (HsExpr GhcRn)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681079770"><span class="hs-identifier hs-var">rn_expr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079768"><span class="hs-identifier hs-var">act_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079760"><span class="hs-identifier hs-var">exp_ty</span></a></span><span>
</span><span id="line-537"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc -&gt; TcM (HsExpr GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; HsExpr GhcTc -&gt; HsExpr GhcTc
</span><a href="GHC.Hs.Utils.html#mkHsWrapCo"><span class="hs-identifier hs-var">mkHsWrapCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079764"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681079769"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-538"></span><span>
</span><span id="line-539"></span><span class="hs-comment">------------------------</span><span>
</span><span id="line-540"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubTypePat"><span class="hs-identifier hs-type">tcSubTypePat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span>
</span><span id="line-541"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpSigmaType"><span class="hs-identifier hs-type">ExpSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-542"></span><span class="hs-comment">-- Used in patterns; polarity is backwards compared</span><span>
</span><span id="line-543"></span><span class="hs-comment">--   to tcSubType</span><span>
</span><span id="line-544"></span><span class="hs-comment">-- If wrap = tc_sub_type_et t1 t2</span><span>
</span><span id="line-545"></span><span class="hs-comment">--    =&gt; wrap :: t1 ~&gt; t2</span><span>
</span><span id="line-546"></span><span id="tcSubTypePat"><span class="annot"><span class="annottext">tcSubTypePat :: CtOrigin -&gt; UserTypeCtxt -&gt; ExpRhoType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubTypePat"><span class="hs-identifier hs-var hs-var">tcSubTypePat</span></a></span></span><span> </span><span id="local-6989586621681079758"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079758"><span class="hs-identifier hs-var">inst_orig</span></a></span></span><span> </span><span id="local-6989586621681079757"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079757"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681079756"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079756"><span class="hs-identifier hs-var">ty_actual</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079755"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079755"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span>
</span><span id="line-547"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcType -&gt; TcM Coercion)
-&gt; CtOrigin -&gt; UserTypeCtxt -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tc_sub_type"><span class="hs-identifier hs-var">tc_sub_type</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyTypeET"><span class="hs-identifier hs-var">unifyTypeET</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079758"><span class="hs-identifier hs-var">inst_orig</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079757"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079756"><span class="hs-identifier hs-var">ty_actual</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079755"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>
</span><span id="line-548"></span><span>
</span><span id="line-549"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubTypePat"><span class="hs-identifier hs-var">tcSubTypePat</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Infer"><span class="hs-identifier hs-type">Infer</span></a></span><span> </span><span id="local-6989586621681079752"><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681079752"><span class="hs-identifier hs-var">inf_res</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079751"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079751"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span>
</span><span id="line-550"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079750"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079750"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; InferResult -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#fillInferResult"><span class="hs-identifier hs-var">fillInferResult</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079751"><span class="hs-identifier hs-var">ty_expected</span></a></span><span> </span><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681079752"><span class="hs-identifier hs-var">inf_res</span></a></span><span>
</span><span id="line-551"></span><span>               </span><span class="hs-comment">-- In patterns we do not instantatiate</span><span>
</span><span id="line-552"></span><span>
</span><span id="line-553"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpCastN"><span class="hs-identifier hs-var">mkWpCastN</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcSymCo"><span class="hs-identifier hs-var">mkTcSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079750"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-554"></span><span>
</span><span id="line-555"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-556"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubType"><span class="hs-identifier hs-type">tcSubType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span>
</span><span id="line-557"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>  </span><span class="hs-comment">-- Actual</span><span>
</span><span id="line-558"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>   </span><span class="hs-comment">-- Expected</span><span>
</span><span id="line-559"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-560"></span><span class="hs-comment">-- Checks that 'actual' is more polymorphic than 'expected'</span><span>
</span><span id="line-561"></span><span id="tcSubType"><span class="annot"><span class="annottext">tcSubType :: CtOrigin -&gt; UserTypeCtxt -&gt; TcType -&gt; ExpRhoType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubType"><span class="hs-identifier hs-var hs-var">tcSubType</span></a></span></span><span> </span><span id="local-6989586621681079748"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079748"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681079747"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079747"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681079746"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079746"><span class="hs-identifier hs-var">ty_actual</span></a></span></span><span> </span><span id="local-6989586621681079745"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079745"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span>
</span><span id="line-562"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType -&gt; TcM HsWrapper -&gt; TcM HsWrapper
forall a. TcType -&gt; ExpRhoType -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Unify.html#addSubTypeCtxt"><span class="hs-identifier hs-var">addSubTypeCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079746"><span class="hs-identifier hs-var">ty_actual</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079745"><span class="hs-identifier hs-var">ty_expected</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM HsWrapper -&gt; TcM HsWrapper) -&gt; TcM HsWrapper -&gt; TcM HsWrapper
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-563"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcSubType&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; SDoc
</span><a href="GHC.Tc.Types.Origin.html#pprUserTypeCtxt"><span class="hs-identifier hs-var">pprUserTypeCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079747"><span class="hs-identifier hs-var">ctxt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079746"><span class="hs-identifier hs-var">ty_actual</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079745"><span class="hs-identifier hs-var">ty_expected</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-564"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; UserTypeCtxt
-&gt; Maybe (HsExpr GhcRn)
-&gt; TcType
-&gt; ExpRhoType
-&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubTypeNC"><span class="hs-identifier hs-var">tcSubTypeNC</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079748"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079747"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079746"><span class="hs-identifier hs-var">ty_actual</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079745"><span class="hs-identifier hs-var">ty_expected</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-565"></span><span>
</span><span id="line-566"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubTypeNC"><span class="hs-identifier hs-type">tcSubTypeNC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>       </span><span class="hs-comment">-- Used when instantiating</span><span>
</span><span id="line-567"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span>   </span><span class="hs-comment">-- Used when skolemising</span><span>
</span><span id="line-568"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- The expression that has type 'actual' (if known)</span><span>
</span><span id="line-569"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>            </span><span class="hs-comment">-- Actual type</span><span>
</span><span id="line-570"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>             </span><span class="hs-comment">-- Expected type</span><span>
</span><span id="line-571"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-572"></span><span id="tcSubTypeNC"><span class="annot"><span class="annottext">tcSubTypeNC :: CtOrigin
-&gt; UserTypeCtxt
-&gt; Maybe (HsExpr GhcRn)
-&gt; TcType
-&gt; ExpRhoType
-&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubTypeNC"><span class="hs-identifier hs-var hs-var">tcSubTypeNC</span></a></span></span><span> </span><span id="local-6989586621681079742"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079742"><span class="hs-identifier hs-var">inst_orig</span></a></span></span><span> </span><span id="local-6989586621681079741"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079741"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681079740"><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079740"><span class="hs-identifier hs-var">m_thing</span></a></span></span><span> </span><span id="local-6989586621681079739"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079739"><span class="hs-identifier hs-var">ty_actual</span></a></span></span><span> </span><span id="local-6989586621681079738"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079738"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-573"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079738"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-574"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681079737"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079737"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcType -&gt; TcM Coercion)
-&gt; CtOrigin -&gt; UserTypeCtxt -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tc_sub_type"><span class="hs-identifier hs-var">tc_sub_type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079740"><span class="hs-identifier hs-var">m_thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079742"><span class="hs-identifier hs-var">inst_orig</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079741"><span class="hs-identifier hs-var">ctxt</span></a></span><span>
</span><span id="line-575"></span><span>                                       </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079739"><span class="hs-identifier hs-var">ty_actual</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079737"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>
</span><span id="line-576"></span><span>
</span><span id="line-577"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Infer"><span class="hs-identifier hs-type">Infer</span></a></span><span> </span><span id="local-6989586621681079736"><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681079736"><span class="hs-identifier hs-var">inf_res</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079735"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079735"><span class="hs-identifier hs-var">wrap</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079734"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079734"><span class="hs-identifier hs-var">rho</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TcType -&gt; TcM (HsWrapper, TcType)
</span><a href="GHC.Tc.Utils.Instantiate.html#topInstantiate"><span class="hs-identifier hs-var">topInstantiate</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079742"><span class="hs-identifier hs-var">inst_orig</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079739"><span class="hs-identifier hs-var">ty_actual</span></a></span><span>
</span><span id="line-578"></span><span>                                   </span><span class="hs-comment">-- See Note [Instantiation of InferResult]</span><span>
</span><span id="line-579"></span><span>                          </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079733"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079733"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; InferResult -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#fillInferResult"><span class="hs-identifier hs-var">fillInferResult</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079734"><span class="hs-identifier hs-var">rho</span></a></span><span> </span><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681079736"><span class="hs-identifier hs-var">inf_res</span></a></span><span>
</span><span id="line-580"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpCastN"><span class="hs-identifier hs-var">mkWpCastN</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079733"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079735"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-581"></span><span>
</span><span id="line-582"></span><span class="hs-comment">{- Note [Instantiation of InferResult]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We now always instantiate before filling in InferResult, so that
the result is a TcRhoType: see #17173 for discussion.

For example:

1. Consider
    f x = (*)
   We want to instantiate the type of (*) before returning, else we
   will infer the type
     f :: forall {a}. a -&gt; forall b. Num b =&gt; b -&gt; b -&gt; b
   This is surely confusing for users.

   And worse, the monomorphism restriction won't work properly. The MR is
   dealt with in simplifyInfer, and simplifyInfer has no way of
   instantiating. This could perhaps be worked around, but it may be
   hard to know even when instantiation should happen.

2. Another reason.  Consider
       f :: (?x :: Int) =&gt; a -&gt; a
       g y = let ?x = 3::Int in f
   Here want to instantiate f's type so that the ?x::Int constraint
   gets discharged by the enclosing implicit-parameter binding.

3. Suppose one defines plus = (+). If we instantiate lazily, we will
   infer plus :: forall a. Num a =&gt; a -&gt; a -&gt; a. However, the monomorphism
   restriction compels us to infer
      plus :: Integer -&gt; Integer -&gt; Integer
   (or similar monotype). Indeed, the only way to know whether to apply
   the monomorphism restriction at all is to instantiate

There is one place where we don't want to instantiate eagerly,
namely in GHC.Tc.Module.tcRnExpr, which implements GHCi's :type
command. See Note [Implementing :type] in GHC.Tc.Module.
-}</span><span>
</span><span id="line-618"></span><span>
</span><span id="line-619"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-620"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubTypeSigma"><span class="hs-identifier hs-type">tcSubTypeSigma</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-621"></span><span class="hs-comment">-- External entry point, but no ExpTypes on either side</span><span>
</span><span id="line-622"></span><span class="hs-comment">-- Checks that actual &lt;= expected</span><span>
</span><span id="line-623"></span><span class="hs-comment">-- Returns HsWrapper :: actual ~ expected</span><span>
</span><span id="line-624"></span><span id="tcSubTypeSigma"><span class="annot"><span class="annottext">tcSubTypeSigma :: UserTypeCtxt -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubTypeSigma"><span class="hs-identifier hs-var hs-var">tcSubTypeSigma</span></a></span></span><span> </span><span id="local-6989586621681079732"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079732"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681079731"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079731"><span class="hs-identifier hs-var">ty_actual</span></a></span></span><span> </span><span id="local-6989586621681079730"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079730"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span>
</span><span id="line-625"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; TcType -&gt; TcM Coercion)
-&gt; CtOrigin -&gt; UserTypeCtxt -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tc_sub_type"><span class="hs-identifier hs-var">tc_sub_type</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079729"><span class="hs-identifier hs-var">eq_orig</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079732"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079731"><span class="hs-identifier hs-var">ty_actual</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079730"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>
</span><span id="line-626"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-627"></span><span>    </span><span id="local-6989586621681079729"><span class="annot"><span class="annottext">eq_orig :: CtOrigin
</span><a href="#local-6989586621681079729"><span class="hs-identifier hs-var hs-var">eq_orig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEqOrigin :: TcType -&gt; TcType -&gt; Maybe SDoc -&gt; Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079731"><span class="hs-identifier hs-var">ty_actual</span></a></span><span>
</span><span id="line-628"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079730"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>
</span><span id="line-629"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_thing :: Maybe SDoc
</span><a href="GHC.Tc.Types.Origin.html#uo_thing"><span class="hs-identifier hs-var">uo_thing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SDoc
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-630"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_visible :: Bool
</span><a href="GHC.Tc.Types.Origin.html#uo_visible"><span class="hs-identifier hs-var">uo_visible</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-631"></span><span>
</span><span id="line-632"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-633"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tc_sub_type"><span class="hs-identifier hs-type">tc_sub_type</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercionN"><span class="hs-identifier hs-type">TcCoercionN</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- How to unify</span><span>
</span><span id="line-634"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>       </span><span class="hs-comment">-- Used when instantiating</span><span>
</span><span id="line-635"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span>   </span><span class="hs-comment">-- Used when skolemising</span><span>
</span><span id="line-636"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>    </span><span class="hs-comment">-- Actual; a sigma-type</span><span>
</span><span id="line-637"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>    </span><span class="hs-comment">-- Expected; also a sigma-type</span><span>
</span><span id="line-638"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-639"></span><span class="hs-comment">-- Checks that actual_ty is more polymorphic than expected_ty</span><span>
</span><span id="line-640"></span><span class="hs-comment">-- If wrap = tc_sub_type t1 t2</span><span>
</span><span id="line-641"></span><span class="hs-comment">--    =&gt; wrap :: t1 ~&gt; t2</span><span>
</span><span id="line-642"></span><span id="tc_sub_type"><span class="annot"><span class="annottext">tc_sub_type :: (TcType -&gt; TcType -&gt; TcM Coercion)
-&gt; CtOrigin -&gt; UserTypeCtxt -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tc_sub_type"><span class="hs-identifier hs-var hs-var">tc_sub_type</span></a></span></span><span> </span><span id="local-6989586621681079723"><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079723"><span class="hs-identifier hs-var">unify</span></a></span></span><span> </span><span id="local-6989586621681079722"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079722"><span class="hs-identifier hs-var">inst_orig</span></a></span></span><span> </span><span id="local-6989586621681079721"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079721"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681079720"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079720"><span class="hs-identifier hs-var">ty_actual</span></a></span></span><span> </span><span id="local-6989586621681079719"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079719"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span>
</span><span id="line-643"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="#local-6989586621681079718"><span class="hs-identifier hs-var">definitely_poly</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079719"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>      </span><span class="hs-comment">-- See Note [Don't skolemise unnecessarily]</span><span>
</span><span id="line-644"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="#local-6989586621681079717"><span class="hs-identifier hs-var">possibly_poly</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079720"><span class="hs-identifier hs-var">ty_actual</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-645"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tc_sub_type (drop to equality)&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-646"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ty_actual   =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079720"><span class="hs-identifier hs-var">ty_actual</span></a></span><span>
</span><span id="line-647"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ty_expected =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079719"><span class="hs-identifier hs-var">ty_expected</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-648"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpCastN"><span class="hs-identifier hs-var">mkWpCastN</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; HsWrapper) -&gt; TcM Coercion -&gt; TcM HsWrapper
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span>
</span><span id="line-649"></span><span>         </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079723"><span class="hs-identifier hs-var">unify</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079720"><span class="hs-identifier hs-var">ty_actual</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079719"><span class="hs-identifier hs-var">ty_expected</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-650"></span><span>
</span><span id="line-651"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- This is the general case</span><span>
</span><span id="line-652"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tc_sub_type (general case)&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-653"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ty_actual   =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079720"><span class="hs-identifier hs-var">ty_actual</span></a></span><span>
</span><span id="line-654"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ty_expected =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079719"><span class="hs-identifier hs-var">ty_expected</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-655"></span><span>
</span><span id="line-656"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079716"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079716"><span class="hs-identifier hs-var">sk_wrap</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079715"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079715"><span class="hs-identifier hs-var">inner_wrap</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-657"></span><span>           </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
-&gt; TcType
-&gt; (TcType -&gt; TcM HsWrapper)
-&gt; TcM (HsWrapper, HsWrapper)
forall result.
UserTypeCtxt
-&gt; TcType -&gt; (TcType -&gt; TcM result) -&gt; TcM (HsWrapper, result)
</span><a href="GHC.Tc.Utils.Unify.html#tcSkolemise"><span class="hs-identifier hs-var">tcSkolemise</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079721"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079719"><span class="hs-identifier hs-var">ty_expected</span></a></span><span> </span><span class="annot"><span class="annottext">((TcType -&gt; TcM HsWrapper) -&gt; TcM (HsWrapper, HsWrapper))
-&gt; (TcType -&gt; TcM HsWrapper) -&gt; TcM (HsWrapper, HsWrapper)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681079714"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079714"><span class="hs-identifier hs-var">sk_rho</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-658"></span><span>              </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079713"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079713"><span class="hs-identifier hs-var">wrap</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079712"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079712"><span class="hs-identifier hs-var">rho_a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TcType -&gt; TcM (HsWrapper, TcType)
</span><a href="GHC.Tc.Utils.Instantiate.html#topInstantiate"><span class="hs-identifier hs-var">topInstantiate</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079722"><span class="hs-identifier hs-var">inst_orig</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079720"><span class="hs-identifier hs-var">ty_actual</span></a></span><span>
</span><span id="line-659"></span><span>                 </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079711"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079711"><span class="hs-identifier hs-var">cow</span></a></span></span><span>           </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079723"><span class="hs-identifier hs-var">unify</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079712"><span class="hs-identifier hs-var">rho_a</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079714"><span class="hs-identifier hs-var">sk_rho</span></a></span><span>
</span><span id="line-660"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpCastN"><span class="hs-identifier hs-var">mkWpCastN</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079711"><span class="hs-identifier hs-var">cow</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079713"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-661"></span><span>
</span><span id="line-662"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079716"><span class="hs-identifier hs-var">sk_wrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079715"><span class="hs-identifier hs-var">inner_wrap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-663"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-664"></span><span>    </span><span id="local-6989586621681079717"><span class="annot"><span class="annottext">possibly_poly :: TcType -&gt; Bool
</span><a href="#local-6989586621681079717"><span class="hs-identifier hs-var hs-var">possibly_poly</span></a></span></span><span> </span><span id="local-6989586621681079710"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079710"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-665"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Core.Type.html#isForAllTy"><span class="hs-identifier hs-var">isForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079710"><span class="hs-identifier hs-var">ty</span></a></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-666"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079708"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079708"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType, TcType)
</span><a href="GHC.Core.Type.html#splitFunTy_maybe"><span class="hs-identifier hs-var">splitFunTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079710"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="#local-6989586621681079717"><span class="hs-identifier hs-var">possibly_poly</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079708"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-667"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-668"></span><span>      </span><span class="hs-comment">-- NB *not* tcSplitFunTy, because here we want</span><span>
</span><span id="line-669"></span><span>      </span><span class="hs-comment">-- to decompose type-class arguments too</span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span>    </span><span id="local-6989586621681079718"><span class="annot"><span class="annottext">definitely_poly :: TcType -&gt; Bool
</span><a href="#local-6989586621681079718"><span class="hs-identifier hs-var hs-var">definitely_poly</span></a></span></span><span> </span><span id="local-6989586621681079705"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079705"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-672"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079704"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079704"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079703"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079703"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079702"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079702"><span class="hs-identifier hs-var">tau</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ([TcTyVar], ThetaType, TcType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitSigmaTy"><span class="hs-identifier hs-var">tcSplitSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079705"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-673"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079701"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079701"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[TcTyVar]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079704"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-674"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079703"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-675"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; TcTyVar -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isInsolubleOccursCheck"><span class="hs-identifier hs-var">isInsolubleOccursCheck</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="GHC.Core.Predicate.html#NomEq"><span class="hs-identifier hs-var">NomEq</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079701"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079702"><span class="hs-identifier hs-var">tau</span></a></span><span>
</span><span id="line-676"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-677"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-678"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-679"></span><span>
</span><span id="line-680"></span><span class="hs-comment">------------------------</span><span>
</span><span id="line-681"></span><span id="local-6989586621681080418"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#addSubTypeCtxt"><span class="hs-identifier hs-type">addSubTypeCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080418"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080418"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-682"></span><span id="addSubTypeCtxt"><span class="annot"><span class="annottext">addSubTypeCtxt :: forall a. TcType -&gt; ExpRhoType -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Unify.html#addSubTypeCtxt"><span class="hs-identifier hs-var hs-var">addSubTypeCtxt</span></a></span></span><span> </span><span id="local-6989586621681079697"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079697"><span class="hs-identifier hs-var">ty_actual</span></a></span></span><span> </span><span id="local-6989586621681079696"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079696"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span> </span><span id="local-6989586621681079695"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681079695"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-683"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isRhoTy"><span class="hs-identifier hs-var">isRhoTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079697"><span class="hs-identifier hs-var">ty_actual</span></a></span><span>        </span><span class="hs-comment">-- If there is no polymorphism involved, the</span><span>
</span><span id="line-684"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isRhoExpTy"><span class="hs-identifier hs-var">isRhoExpTy</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079696"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>   </span><span class="hs-comment">-- TypeEqOrigin stuff (added by the _NC functions)</span><span>
</span><span id="line-685"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681079695"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>             </span><span class="hs-comment">-- gives enough context by itself</span><span>
</span><span id="line-686"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-687"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv -&gt; TcM (TidyEnv, SDoc)) -&gt; TcM a -&gt; TcM a
forall a. (TidyEnv -&gt; TcM (TidyEnv, SDoc)) -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxtM"><span class="hs-identifier hs-var">addErrCtxtM</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="#local-6989586621681079693"><span class="hs-identifier hs-var">mk_msg</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681079695"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-688"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-689"></span><span>    </span><span id="local-6989586621681079693"><span class="annot"><span class="annottext">mk_msg :: TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="#local-6989586621681079693"><span class="hs-identifier hs-var hs-var">mk_msg</span></a></span></span><span> </span><span id="local-6989586621681079682"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079682"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span>
</span><span id="line-690"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079681"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079681"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079680"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079680"><span class="hs-identifier hs-var">ty_actual</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcType -&gt; TcM (TidyEnv, TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079682"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079697"><span class="hs-identifier hs-var">ty_actual</span></a></span><span>
</span><span id="line-691"></span><span>                   </span><span class="hs-comment">-- might not be filled if we're debugging. ugh.</span><span>
</span><span id="line-692"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079679"><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681079679"><span class="hs-identifier hs-var">mb_ty_expected</span></a></span></span><span>          </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; TcM (Maybe TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType_maybe"><span class="hs-identifier hs-var">readExpType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079696"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>
</span><span id="line-693"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079677"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079677"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079676"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079676"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="#local-6989586621681079679"><span class="hs-identifier hs-var">mb_ty_expected</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-694"></span><span>                                          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079675"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079675"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; ExpRhoType)
-&gt; (TidyEnv, TcType) -&gt; (TidyEnv, ExpRhoType)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (d, b) (d, c)
</span><a href="../../base/src/Control.Arrow.html#second"><span class="hs-identifier hs-var">second</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType
</span><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier hs-var">mkCheckExpType</span></a></span><span> </span><span class="annot"><span class="annottext">((TidyEnv, TcType) -&gt; (TidyEnv, ExpRhoType))
-&gt; TcM (TidyEnv, TcType)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TidyEnv, ExpRhoType)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span>
</span><span id="line-695"></span><span>                                                     </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcType -&gt; TcM (TidyEnv, TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079681"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079675"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-696"></span><span>                                          </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, ExpRhoType)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TidyEnv, ExpRhoType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079681"><span class="hs-identifier hs-var">tidy_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079696"><span class="hs-identifier hs-var">ty_expected</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-697"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079674"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079674"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-var">readExpType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079676"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>
</span><span id="line-698"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079673"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079673"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079672"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079672"><span class="hs-identifier hs-var">ty_expected</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcType -&gt; TcM (TidyEnv, TcType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079677"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079674"><span class="hs-identifier hs-var">ty_expected</span></a></span><span>
</span><span id="line-699"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079669"><span class="annot"><span class="annottext">msg :: SDoc
</span><a href="#local-6989586621681079669"><span class="hs-identifier hs-var hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;When checking that:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-700"></span><span>                                 </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079680"><span class="hs-identifier hs-var">ty_actual</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-701"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is more polymorphic than:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-702"></span><span>                                         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079672"><span class="hs-identifier hs-var">ty_expected</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-703"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681079673"><span class="hs-identifier hs-var">tidy_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079669"><span class="hs-identifier hs-var">msg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-704"></span><span>
</span><span id="line-705"></span><span class="hs-comment">{- Note [Don't skolemise unnecessarily]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we are trying to solve
    (Char-&gt;Char) &lt;= (forall a. a-&gt;a)
We could skolemise the 'forall a', and then complain
that (Char ~ a) is insoluble; but that's a pretty obscure
error.  It's better to say that
    (Char-&gt;Char) ~ (forall a. a-&gt;a)
fails.

So roughly:
 * if the ty_expected has an outermost forall
      (i.e. skolemisation is the next thing we'd do)
 * and the ty_actual has no top-level polymorphism (but looking deeply)
then we can revert to simple equality.  But we need to be careful.
These examples are all fine:

 * (Char -&gt; forall a. a-&gt;a) &lt;= (forall a. Char -&gt; a -&gt; a)
      Polymorphism is buried in ty_actual

 * (Char-&gt;Char) &lt;= (forall a. Char -&gt; Char)
      ty_expected isn't really polymorphic

 * (Char-&gt;Char) &lt;= (forall a. (a~Char) =&gt; a -&gt; a)
      ty_expected isn't really polymorphic

 * (Char-&gt;Char) &lt;= (forall a. F [a] Char -&gt; Char)
                   where type instance F [x] t = t
     ty_expected isn't really polymorphic

If we prematurely go to equality we'll reject a program we should
accept (e.g. #13752).  So the test (which is only to improve
error message) is very conservative:
 * ty_actual is /definitely/ monomorphic
 * ty_expected is /definitely/ polymorphic

Note [Settting the argument context]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider we are doing the ambiguity check for the (bogus)
  f :: (forall a b. C b =&gt; a -&gt; a) -&gt; Int

We'll call
   tcSubType ((forall a b. C b =&gt; a-&gt;a) -&gt; Int )
             ((forall a b. C b =&gt; a-&gt;a) -&gt; Int )

with a UserTypeCtxt of (FunSigCtxt &quot;f&quot;).  Then we'll do the co/contra thing
on the argument type of the (-&gt;) -- and at that point we want to switch
to a UserTypeCtxt of GenSigCtxt.  Why?

* Error messages.  If we stick with FunSigCtxt we get errors like
     * Could not deduce: C b
       from the context: C b0
        bound by the type signature for:
            f :: forall a b. C b =&gt; a-&gt;a
  But of course f does not have that type signature!
  Example tests: T10508, T7220a, Simple14

* Implications. We may decide to build an implication for the whole
  ambiguity check, but we don't need one for each level within it,
  and GHC.Tc.Utils.Unify.alwaysBuildImplication checks the UserTypeCtxt.
  See Note [When to build an implication]

Note [Wrapper returned from tcSubMult]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is no notion of multiplicity coercion in Core, therefore the wrapper
returned by tcSubMult (and derived functions such as tcCheckUsage and
checkManyPattern) is quite unlike any other wrapper: it checks whether the
coercion produced by the constraint solver is trivial, producing a type error
is it is not. This is implemented via the WpMultCoercion wrapper, as desugared
by GHC.HsToCore.Binds.dsHsWrapper, which does the reflexivity check.

This wrapper needs to be placed in the term; otherwise, checking of the
eventual coercion won't be triggered during desugaring. But it can be put
anywhere, since it doesn't affect the desugared code.

Why do we check this in the desugarer? It's a convenient place, since it's
right after all the constraints are solved. We need the constraints to be
solved to check whether they are trivial or not. Plus there is precedent for
type errors during desuraging (such as the levity polymorphism
restriction). An alternative would be to have a kind of constraint which can
only produce trivial evidence, then this check would happen in the constraint
solver.
-}</span><span>
</span><span id="line-788"></span><span>
</span><span id="line-789"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier hs-type">tcSubMult</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-790"></span><span id="tcSubMult"><span class="annot"><span class="annottext">tcSubMult :: CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier hs-var hs-var">tcSubMult</span></a></span></span><span> </span><span id="local-6989586621681079666"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079666"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079665"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079665"><span class="hs-identifier hs-var">w_actual</span></a></span></span><span> </span><span id="local-6989586621681079664"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079664"><span class="hs-identifier hs-var">w_expected</span></a></span></span><span>
</span><span id="line-791"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079663"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079663"><span class="hs-identifier hs-var">w1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079662"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079662"><span class="hs-identifier hs-var">w2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe (TcType, TcType)
</span><a href="GHC.Core.Multiplicity.html#isMultMul"><span class="hs-identifier hs-var">isMultMul</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079665"><span class="hs-identifier hs-var">w_actual</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-792"></span><span>  </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079660"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079660"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier hs-var">tcSubMult</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079666"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079663"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079664"><span class="hs-identifier hs-var">w_expected</span></a></span><span>
</span><span id="line-793"></span><span>     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079659"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079659"><span class="hs-identifier hs-var">w2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier hs-var">tcSubMult</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079666"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079662"><span class="hs-identifier hs-var">w2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079664"><span class="hs-identifier hs-var">w_expected</span></a></span><span>
</span><span id="line-794"></span><span>     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079660"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079659"><span class="hs-identifier hs-var">w2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-795"></span><span>  </span><span class="hs-comment">-- Currently, we consider p*q and sup p q to be equal.  Therefore, p*q &lt;= r is</span><span>
</span><span id="line-796"></span><span>  </span><span class="hs-comment">-- equivalent to p &lt;= r and q &lt;= r.  For other cases, we approximate p &lt;= q by p</span><span>
</span><span id="line-797"></span><span>  </span><span class="hs-comment">-- ~ q.  This is not complete, but it's sound. See also Note [Overapproximating</span><span>
</span><span id="line-798"></span><span>  </span><span class="hs-comment">-- multiplicities] in Multiplicity.</span><span>
</span><span id="line-799"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier hs-var">tcSubMult</span></a></span><span> </span><span id="local-6989586621681079658"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079658"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079657"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079657"><span class="hs-identifier hs-var">w_actual</span></a></span></span><span> </span><span id="local-6989586621681079656"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079656"><span class="hs-identifier hs-var">w_expected</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-800"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; IsSubmult
</span><a href="GHC.Core.Multiplicity.html#submult"><span class="hs-identifier hs-var">submult</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079657"><span class="hs-identifier hs-var">w_actual</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079656"><span class="hs-identifier hs-var">w_expected</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-801"></span><span>    </span><span class="annot"><span class="annottext">IsSubmult
</span><a href="GHC.Core.Multiplicity.html#Submult"><span class="hs-identifier hs-var">Submult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#WpHole"><span class="hs-identifier hs-var">WpHole</span></a></span><span>
</span><span id="line-802"></span><span>    </span><span class="annot"><span class="annottext">IsSubmult
</span><a href="GHC.Core.Multiplicity.html#Unknown"><span class="hs-identifier hs-var">Unknown</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcEqMult"><span class="hs-identifier hs-var">tcEqMult</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079658"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079657"><span class="hs-identifier hs-var">w_actual</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079656"><span class="hs-identifier hs-var">w_expected</span></a></span><span>
</span><span id="line-803"></span><span>
</span><span id="line-804"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcEqMult"><span class="hs-identifier hs-type">tcEqMult</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-805"></span><span id="tcEqMult"><span class="annot"><span class="annottext">tcEqMult :: CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcEqMult"><span class="hs-identifier hs-var hs-var">tcEqMult</span></a></span></span><span> </span><span id="local-6989586621681079650"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079650"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079649"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079649"><span class="hs-identifier hs-var">w_actual</span></a></span></span><span> </span><span id="local-6989586621681079648"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079648"><span class="hs-identifier hs-var">w_expected</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-806"></span><span>  </span><span class="hs-special">{</span><span>
</span><span id="line-807"></span><span>  </span><span class="hs-comment">-- Note that here we do not call to `submult`, so we check</span><span>
</span><span id="line-808"></span><span>  </span><span class="hs-comment">-- for strict equality.</span><span>
</span><span id="line-809"></span><span>  </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079647"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079647"><span class="hs-identifier hs-var">coercion</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#TypeLevel"><span class="hs-identifier hs-var">TypeLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079650"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079649"><span class="hs-identifier hs-var">w_actual</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079648"><span class="hs-identifier hs-var">w_expected</span></a></span><span>
</span><span id="line-810"></span><span>  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(HsWrapper -&gt; TcM HsWrapper) -&gt; HsWrapper -&gt; TcM HsWrapper
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Core.Coercion.html#isReflCo"><span class="hs-identifier hs-var">isReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079647"><span class="hs-identifier hs-var">coercion</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#WpHole"><span class="hs-identifier hs-var">WpHole</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#WpMultCoercion"><span class="hs-identifier hs-var">WpMultCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079647"><span class="hs-identifier hs-var">coercion</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-811"></span><span>
</span><span id="line-812"></span><span>
</span><span id="line-813"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                    Generalisation
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-818"></span><span>
</span><span id="line-819"></span><span class="hs-comment">{- Note [Skolemisation]
~~~~~~~~~~~~~~~~~~~~~~~
tcSkolemise takes &quot;expected type&quot; and strip off quantifiers to expose the
type underneath, binding the new skolems for the 'thing_inside'
The returned 'HsWrapper' has type (specific_ty -&gt; expected_ty).

Note that for a nested type like
   forall a. Eq a =&gt; forall b. Ord b =&gt; blah
we still only build one implication constraint
   forall a b. (Eq a, Ord b) =&gt; &lt;constraints&gt;
This is just an optimisation, but it's why we use topSkolemise to
build the pieces from all the layers, before making a single call
to checkConstraints.

tcSkolemiseScoped is very similar, but differs in two ways:

* It deals specially with just the outer forall, bringing those
  type variables into lexical scope.  To my surprise, I found that
  doing this regardless (in tcSkolemise) caused a non-trivial (1%-ish)
  perf hit on the compiler.

* It always calls checkConstraints, even if there are no skolem
  variables at all.  Reason: there might be nested deferred errors
  that must not be allowed to float to top level.
  See Note [When to build an implication] below.
-}</span><span>
</span><span id="line-845"></span><span>
</span><span id="line-846"></span><span id="local-6989586621681080457"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSkolemise"><span class="hs-identifier hs-type">tcSkolemise</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSkolemiseScoped"><span class="hs-identifier hs-type">tcSkolemiseScoped</span></a></span><span>
</span><span id="line-847"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>
</span><span id="line-848"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080457"><span class="hs-identifier hs-type">result</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-849"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681080457"><span class="hs-identifier hs-type">result</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-850"></span><span>        </span><span class="hs-comment">-- ^ The wrapper has type: spec_ty ~&gt; expected_ty</span><span>
</span><span id="line-851"></span><span>
</span><span id="line-852"></span><span id="tcSkolemiseScoped"><span class="annot"><span class="annottext">tcSkolemiseScoped :: forall result.
UserTypeCtxt
-&gt; TcType -&gt; (TcType -&gt; TcM result) -&gt; TcM (HsWrapper, result)
</span><a href="GHC.Tc.Utils.Unify.html#tcSkolemiseScoped"><span class="hs-identifier hs-var hs-var">tcSkolemiseScoped</span></a></span></span><span> </span><span id="local-6989586621681079640"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079640"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681079639"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079639"><span class="hs-identifier hs-var">expected_ty</span></a></span></span><span> </span><span id="local-6989586621681079638"><span class="annot"><span class="annottext">TcType -&gt; TcM result
</span><a href="#local-6989586621681079638"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-853"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079637"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079637"><span class="hs-identifier hs-var">wrap</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079636"><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><a href="#local-6989586621681079636"><span class="hs-identifier hs-var">tv_prs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079635"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079635"><span class="hs-identifier hs-var">given</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079634"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079634"><span class="hs-identifier hs-var">rho_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, [(Name, TcTyVar)], [TcTyVar], TcType)
</span><a href="GHC.Tc.Utils.Instantiate.html#topSkolemise"><span class="hs-identifier hs-var">topSkolemise</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079639"><span class="hs-identifier hs-var">expected_ty</span></a></span><span>
</span><span id="line-854"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079632"><span class="annot"><span class="annottext">skol_tvs :: [TcTyVar]
</span><a href="#local-6989586621681079632"><span class="hs-identifier hs-var hs-var">skol_tvs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Name, TcTyVar) -&gt; TcTyVar) -&gt; [(Name, TcTyVar)] -&gt; [TcTyVar]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, TcTyVar) -&gt; TcTyVar
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><a href="#local-6989586621681079636"><span class="hs-identifier hs-var">tv_prs</span></a></span><span>
</span><span id="line-855"></span><span>             </span><span id="local-6989586621681079631"><span class="annot"><span class="annottext">skol_info :: SkolemInfo
</span><a href="#local-6989586621681079631"><span class="hs-identifier hs-var hs-var">skol_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; TcType -&gt; [(Name, TcTyVar)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#SigSkol"><span class="hs-identifier hs-var">SigSkol</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079640"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079639"><span class="hs-identifier hs-var">expected_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><a href="#local-6989586621681079636"><span class="hs-identifier hs-var">tv_prs</span></a></span><span>
</span><span id="line-856"></span><span>
</span><span id="line-857"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079629"><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681079629"><span class="hs-identifier hs-var">ev_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079628"><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079628"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-858"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
-&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; TcM result -&gt; TcM (TcEvBinds, result)
forall result.
SkolemInfo
-&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; TcM result -&gt; TcM (TcEvBinds, result)
</span><a href="GHC.Tc.Utils.Unify.html#checkConstraints"><span class="hs-identifier hs-var">checkConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079631"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079632"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079635"><span class="hs-identifier hs-var">given</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM result -&gt; TcM (TcEvBinds, result))
-&gt; TcM result -&gt; TcM (TcEvBinds, result)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-859"></span><span>                </span><span class="annot"><span class="annottext">[(Name, TcTyVar)] -&gt; TcM result -&gt; TcM result
forall r. [(Name, TcTyVar)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendNameTyVarEnv"><span class="hs-identifier hs-var">tcExtendNameTyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><a href="#local-6989586621681079636"><span class="hs-identifier hs-var">tv_prs</span></a></span><span>               </span><span class="annot"><span class="annottext">(TcM result -&gt; TcM result) -&gt; TcM result -&gt; TcM result
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-860"></span><span>                </span><span class="annot"><span class="annottext">TcType -&gt; TcM result
</span><a href="#local-6989586621681079638"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079634"><span class="hs-identifier hs-var">rho_ty</span></a></span><span>
</span><span id="line-861"></span><span>
</span><span id="line-862"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, result) -&gt; TcM (HsWrapper, result)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079637"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvBinds -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpLet"><span class="hs-identifier hs-var">mkWpLet</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681079629"><span class="hs-identifier hs-var">ev_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079628"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-863"></span><span>
</span><span id="line-864"></span><span id="tcSkolemise"><span class="annot"><span class="annottext">tcSkolemise :: forall result.
UserTypeCtxt
-&gt; TcType -&gt; (TcType -&gt; TcM result) -&gt; TcM (HsWrapper, result)
</span><a href="GHC.Tc.Utils.Unify.html#tcSkolemise"><span class="hs-identifier hs-var hs-var">tcSkolemise</span></a></span></span><span> </span><span id="local-6989586621681079620"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079620"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span id="local-6989586621681079619"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079619"><span class="hs-identifier hs-var">expected_ty</span></a></span></span><span> </span><span id="local-6989586621681079618"><span class="annot"><span class="annottext">TcType -&gt; TcM result
</span><a href="#local-6989586621681079618"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-865"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isRhoTy"><span class="hs-identifier hs-var">isRhoTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079619"><span class="hs-identifier hs-var">expected_ty</span></a></span><span>  </span><span class="hs-comment">-- Short cut for common case</span><span>
</span><span id="line-866"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079617"><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079617"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM result
</span><a href="#local-6989586621681079618"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079619"><span class="hs-identifier hs-var">expected_ty</span></a></span><span>
</span><span id="line-867"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, result) -&gt; TcM (HsWrapper, result)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079617"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-868"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-869"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079616"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079616"><span class="hs-identifier hs-var">wrap</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079615"><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><a href="#local-6989586621681079615"><span class="hs-identifier hs-var">tv_prs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079614"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079614"><span class="hs-identifier hs-var">given</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079613"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079613"><span class="hs-identifier hs-var">rho_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcM (HsWrapper, [(Name, TcTyVar)], [TcTyVar], TcType)
</span><a href="GHC.Tc.Utils.Instantiate.html#topSkolemise"><span class="hs-identifier hs-var">topSkolemise</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079619"><span class="hs-identifier hs-var">expected_ty</span></a></span><span>
</span><span id="line-870"></span><span>
</span><span id="line-871"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079612"><span class="annot"><span class="annottext">skol_tvs :: [TcTyVar]
</span><a href="#local-6989586621681079612"><span class="hs-identifier hs-var hs-var">skol_tvs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Name, TcTyVar) -&gt; TcTyVar) -&gt; [(Name, TcTyVar)] -&gt; [TcTyVar]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, TcTyVar) -&gt; TcTyVar
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><a href="#local-6989586621681079615"><span class="hs-identifier hs-var">tv_prs</span></a></span><span>
</span><span id="line-872"></span><span>              </span><span id="local-6989586621681079611"><span class="annot"><span class="annottext">skol_info :: SkolemInfo
</span><a href="#local-6989586621681079611"><span class="hs-identifier hs-var hs-var">skol_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; TcType -&gt; [(Name, TcTyVar)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#SigSkol"><span class="hs-identifier hs-var">SigSkol</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079620"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079619"><span class="hs-identifier hs-var">expected_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyVar)]
</span><a href="#local-6989586621681079615"><span class="hs-identifier hs-var">tv_prs</span></a></span><span>
</span><span id="line-873"></span><span>
</span><span id="line-874"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079610"><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681079610"><span class="hs-identifier hs-var">ev_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079609"><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079609"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-875"></span><span>              </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
-&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; TcM result -&gt; TcM (TcEvBinds, result)
forall result.
SkolemInfo
-&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; TcM result -&gt; TcM (TcEvBinds, result)
</span><a href="GHC.Tc.Utils.Unify.html#checkConstraints"><span class="hs-identifier hs-var">checkConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079611"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079612"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079614"><span class="hs-identifier hs-var">given</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM result -&gt; TcM (TcEvBinds, result))
-&gt; TcM result -&gt; TcM (TcEvBinds, result)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-876"></span><span>                 </span><span class="annot"><span class="annottext">TcType -&gt; TcM result
</span><a href="#local-6989586621681079618"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079613"><span class="hs-identifier hs-var">rho_ty</span></a></span><span>
</span><span id="line-877"></span><span>
</span><span id="line-878"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, result) -&gt; TcM (HsWrapper, result)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681079616"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvBinds -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpLet"><span class="hs-identifier hs-var">mkWpLet</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681079610"><span class="hs-identifier hs-var">ev_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079609"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-879"></span><span>          </span><span class="hs-comment">-- The ev_binds returned by checkConstraints is very</span><span>
</span><span id="line-880"></span><span>          </span><span class="hs-comment">-- often empty, in which case mkWpLet is a no-op</span><span>
</span><span id="line-881"></span><span>
</span><span id="line-882"></span><span class="hs-comment">-- | Variant of 'tcSkolemise' that takes an ExpType</span><span>
</span><span id="line-883"></span><span id="local-6989586621681080400"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSkolemiseET"><span class="hs-identifier hs-type">tcSkolemiseET</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpSigmaType"><span class="hs-identifier hs-type">ExpSigmaType</span></a></span><span>
</span><span id="line-884"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080400"><span class="hs-identifier hs-type">result</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-885"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681080400"><span class="hs-identifier hs-type">result</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-886"></span><span id="tcSkolemiseET"><span class="annot"><span class="annottext">tcSkolemiseET :: forall result.
UserTypeCtxt
-&gt; ExpRhoType
-&gt; (ExpRhoType -&gt; TcM result)
-&gt; TcM (HsWrapper, result)
</span><a href="GHC.Tc.Utils.Unify.html#tcSkolemiseET"><span class="hs-identifier hs-var hs-var">tcSkolemiseET</span></a></span></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681079607"><span class="annot"><span class="annottext">et :: ExpRhoType
</span><a href="#local-6989586621681079607"><span class="hs-identifier hs-var">et</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Infer"><span class="hs-identifier hs-type">Infer</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079606"><span class="annot"><span class="annottext">ExpRhoType -&gt; TcM result
</span><a href="#local-6989586621681079606"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-887"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(result -&gt; (HsWrapper, result))
-&gt; TcM result -&gt; IOEnv (Env TcGblEnv TcLclEnv) (HsWrapper, result)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; TcM result
</span><a href="#local-6989586621681079606"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681079607"><span class="hs-identifier hs-var">et</span></a></span><span>
</span><span id="line-888"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSkolemiseET"><span class="hs-identifier hs-var">tcSkolemiseET</span></a></span><span> </span><span id="local-6989586621681079605"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079605"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681079604"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079604"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079603"><span class="annot"><span class="annottext">ExpRhoType -&gt; TcM result
</span><a href="#local-6989586621681079603"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-889"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
-&gt; TcType
-&gt; (TcType -&gt; TcM result)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (HsWrapper, result)
forall result.
UserTypeCtxt
-&gt; TcType -&gt; (TcType -&gt; TcM result) -&gt; TcM (HsWrapper, result)
</span><a href="GHC.Tc.Utils.Unify.html#tcSkolemise"><span class="hs-identifier hs-var">tcSkolemise</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681079605"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079604"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">((TcType -&gt; TcM result)
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (HsWrapper, result))
-&gt; (TcType -&gt; TcM result)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (HsWrapper, result)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681079602"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079602"><span class="hs-identifier hs-var">rho_ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-890"></span><span>    </span><span class="annot"><span class="annottext">ExpRhoType -&gt; TcM result
</span><a href="#local-6989586621681079603"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; ExpRhoType
</span><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier hs-var">mkCheckExpType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079602"><span class="hs-identifier hs-var">rho_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-891"></span><span>
</span><span id="line-892"></span><span id="local-6989586621681080403"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#checkConstraints"><span class="hs-identifier hs-type">checkConstraints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span>
</span><span id="line-893"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>           </span><span class="hs-comment">-- Skolems</span><span>
</span><span id="line-894"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span>             </span><span class="hs-comment">-- Given</span><span>
</span><span id="line-895"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080403"><span class="hs-identifier hs-type">result</span></a></span><span>
</span><span id="line-896"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-type">TcEvBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681080403"><span class="hs-identifier hs-type">result</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-897"></span><span>
</span><span id="line-898"></span><span id="checkConstraints"><span class="annot"><span class="annottext">checkConstraints :: forall result.
SkolemInfo
-&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; TcM result -&gt; TcM (TcEvBinds, result)
</span><a href="GHC.Tc.Utils.Unify.html#checkConstraints"><span class="hs-identifier hs-var hs-var">checkConstraints</span></a></span></span><span> </span><span id="local-6989586621681079590"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079590"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span id="local-6989586621681079589"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079589"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span> </span><span id="local-6989586621681079588"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079588"><span class="hs-identifier hs-var">given</span></a></span></span><span> </span><span id="local-6989586621681079587"><span class="annot"><span class="annottext">TcM result
</span><a href="#local-6989586621681079587"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-899"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079586"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079586"><span class="hs-identifier hs-var">implication_needed</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.Unify.html#implicationNeeded"><span class="hs-identifier hs-var">implicationNeeded</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079590"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079589"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079588"><span class="hs-identifier hs-var">given</span></a></span><span>
</span><span id="line-900"></span><span>
</span><span id="line-901"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079586"><span class="hs-identifier hs-var">implication_needed</span></a></span><span>
</span><span id="line-902"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079584"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079584"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079583"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079583"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079582"><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079582"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM result -&gt; TcM (TcLevel, WantedConstraints, result)
forall a. TcM a -&gt; TcM (TcLevel, WantedConstraints, a)
</span><a href="GHC.Tc.Utils.Monad.html#pushLevelAndCaptureConstraints"><span class="hs-identifier hs-var">pushLevelAndCaptureConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">TcM result
</span><a href="#local-6989586621681079587"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-903"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079580"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681079580"><span class="hs-identifier hs-var">implics</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079579"><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681079579"><span class="hs-identifier hs-var">ev_binds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel
-&gt; SkolemInfo
-&gt; [TcTyVar]
-&gt; [TcTyVar]
-&gt; WantedConstraints
-&gt; TcM (Bag Implication, TcEvBinds)
</span><a href="GHC.Tc.Utils.Unify.html#buildImplicationFor"><span class="hs-identifier hs-var">buildImplicationFor</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079584"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079590"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079589"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079588"><span class="hs-identifier hs-var">given</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079583"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-904"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkConstraints&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079584"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079589"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-905"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitImplications"><span class="hs-identifier hs-var">emitImplications</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681079580"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-906"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcEvBinds, result) -&gt; TcM (TcEvBinds, result)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681079579"><span class="hs-identifier hs-var">ev_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079582"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-907"></span><span>
</span><span id="line-908"></span><span>         </span><span class="hs-keyword">else</span><span> </span><span class="hs-comment">-- Fast path.  We check every function argument with tcCheckPolyExpr,</span><span>
</span><span id="line-909"></span><span>              </span><span class="hs-comment">-- which uses tcSkolemise and hence checkConstraints.</span><span>
</span><span id="line-910"></span><span>              </span><span class="hs-comment">-- So this fast path is well-exercised</span><span>
</span><span id="line-911"></span><span>              </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079577"><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079577"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM result
</span><a href="#local-6989586621681079587"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-912"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcEvBinds, result) -&gt; TcM (TcEvBinds, result)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#emptyTcEvBinds"><span class="hs-identifier hs-var">emptyTcEvBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079577"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-913"></span><span>
</span><span id="line-914"></span><span id="local-6989586621681080393"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#checkTvConstraints"><span class="hs-identifier hs-type">checkTvConstraints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span>
</span><span id="line-915"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- Skolem tyvars</span><span>
</span><span id="line-916"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080393"><span class="hs-identifier hs-type">result</span></a></span><span>
</span><span id="line-917"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080393"><span class="hs-identifier hs-type">result</span></a></span></span><span>
</span><span id="line-918"></span><span>
</span><span id="line-919"></span><span id="checkTvConstraints"><span class="annot"><span class="annottext">checkTvConstraints :: forall result. SkolemInfo -&gt; [TcTyVar] -&gt; TcM result -&gt; TcM result
</span><a href="GHC.Tc.Utils.Unify.html#checkTvConstraints"><span class="hs-identifier hs-var hs-var">checkTvConstraints</span></a></span></span><span> </span><span id="local-6989586621681079572"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079572"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span id="local-6989586621681079571"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079571"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span> </span><span id="local-6989586621681079570"><span class="annot"><span class="annottext">TcM result
</span><a href="#local-6989586621681079570"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-920"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079569"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079569"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079568"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079568"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079567"><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079567"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM result -&gt; TcM (TcLevel, WantedConstraints, result)
forall a. TcM a -&gt; TcM (TcLevel, WantedConstraints, a)
</span><a href="GHC.Tc.Utils.Monad.html#pushLevelAndCaptureConstraints"><span class="hs-identifier hs-var">pushLevelAndCaptureConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">TcM result
</span><a href="#local-6989586621681079570"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-921"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; [TcTyVar] -&gt; TcLevel -&gt; WantedConstraints -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Unify.html#emitResidualTvConstraint"><span class="hs-identifier hs-var">emitResidualTvConstraint</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079572"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079571"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079569"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079568"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-922"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">result -&gt; TcM result
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681079567"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-923"></span><span>
</span><span id="line-924"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#emitResidualTvConstraint"><span class="hs-identifier hs-type">emitResidualTvConstraint</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-925"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-926"></span><span id="emitResidualTvConstraint"><span class="annot"><span class="annottext">emitResidualTvConstraint :: SkolemInfo -&gt; [TcTyVar] -&gt; TcLevel -&gt; WantedConstraints -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Unify.html#emitResidualTvConstraint"><span class="hs-identifier hs-var hs-var">emitResidualTvConstraint</span></a></span></span><span> </span><span id="local-6989586621681079566"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079566"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span id="local-6989586621681079565"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079565"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span> </span><span id="local-6989586621681079564"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079564"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span id="local-6989586621681079563"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079563"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-927"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079563"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-928"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-929"></span><span>
</span><span id="line-930"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-931"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079561"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681079561"><span class="hs-identifier hs-var">implic</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
-&gt; [TcTyVar] -&gt; TcLevel -&gt; WantedConstraints -&gt; TcM Implication
</span><a href="GHC.Tc.Utils.Unify.html#buildTvImplication"><span class="hs-identifier hs-var">buildTvImplication</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079566"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079565"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079564"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079563"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-932"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitImplication"><span class="hs-identifier hs-var">emitImplication</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681079561"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-933"></span><span>
</span><span id="line-934"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#buildTvImplication"><span class="hs-identifier hs-type">buildTvImplication</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-935"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>
</span><span id="line-936"></span><span id="buildTvImplication"><span class="annot"><span class="annottext">buildTvImplication :: SkolemInfo
-&gt; [TcTyVar] -&gt; TcLevel -&gt; WantedConstraints -&gt; TcM Implication
</span><a href="GHC.Tc.Utils.Unify.html#buildTvImplication"><span class="hs-identifier hs-var hs-var">buildTvImplication</span></a></span></span><span> </span><span id="local-6989586621681079559"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079559"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span id="local-6989586621681079558"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079558"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span> </span><span id="local-6989586621681079557"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079557"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span id="local-6989586621681079556"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079556"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-937"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079555"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681079555"><span class="hs-identifier hs-var">ev_binds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM EvBindsVar
</span><a href="GHC.Tc.Utils.Monad.html#newNoTcEvBinds"><span class="hs-identifier hs-var">newNoTcEvBinds</span></a></span><span>  </span><span class="hs-comment">-- Used for equalities only, so all the constraints</span><span>
</span><span id="line-938"></span><span>                                     </span><span class="hs-comment">-- are solved by filling in coercion holes, not</span><span>
</span><span id="line-939"></span><span>                                     </span><span class="hs-comment">-- by creating a value-level evidence binding</span><span>
</span><span id="line-940"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079553"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681079553"><span class="hs-identifier hs-var">implic</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Implication
</span><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier hs-var">newImplication</span></a></span><span>
</span><span id="line-941"></span><span>
</span><span id="line-942"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcM Implication
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681079553"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_tclvl :: TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ic_tclvl"><span class="hs-identifier hs-var">ic_tclvl</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079557"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-943"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_skols :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079558"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span>
</span><span id="line-944"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_no_eqs :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#ic_no_eqs"><span class="hs-identifier hs-var">ic_no_eqs</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-945"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079556"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-946"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681079555"><span class="hs-identifier hs-var">ev_binds</span></a></span><span>
</span><span id="line-947"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079559"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-948"></span><span>
</span><span id="line-949"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#implicationNeeded"><span class="hs-identifier hs-type">implicationNeeded</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-950"></span><span class="hs-comment">-- See Note [When to build an implication]</span><span>
</span><span id="line-951"></span><span id="implicationNeeded"><span class="annot"><span class="annottext">implicationNeeded :: SkolemInfo -&gt; [TcTyVar] -&gt; [TcTyVar] -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.Unify.html#implicationNeeded"><span class="hs-identifier hs-var hs-var">implicationNeeded</span></a></span></span><span> </span><span id="local-6989586621681079545"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079545"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span id="local-6989586621681079544"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079544"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span> </span><span id="local-6989586621681079543"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079543"><span class="hs-identifier hs-var">given</span></a></span></span><span>
</span><span id="line-952"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079544"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span>
</span><span id="line-953"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079543"><span class="hs-identifier hs-var">given</span></a></span><span>
</span><span id="line-954"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SkolemInfo -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#alwaysBuildImplication"><span class="hs-identifier hs-var">alwaysBuildImplication</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079545"><span class="hs-identifier hs-var">skol_info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-955"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- Empty skolems and givens</span><span>
</span><span id="line-956"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079541"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079541"><span class="hs-identifier hs-var">tc_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-957"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTopTcLevel"><span class="hs-identifier hs-var">isTopTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079541"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- No implication needed if we are</span><span>
</span><span id="line-958"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>             </span><span class="hs-comment">-- already inside an implication</span><span>
</span><span id="line-959"></span><span>         </span><span class="hs-keyword">else</span><span>
</span><span id="line-960"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079538"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079538"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>       </span><span class="hs-comment">-- If any deferral can happen,</span><span>
</span><span id="line-961"></span><span>                                     </span><span class="hs-comment">-- we must build an implication</span><span>
</span><span id="line-962"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_DeferTypeErrors"><span class="hs-identifier hs-var">Opt_DeferTypeErrors</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079538"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-963"></span><span>                 </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_DeferTypedHoles"><span class="hs-identifier hs-var">Opt_DeferTypedHoles</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079538"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span>
</span><span id="line-964"></span><span>                 </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_DeferOutOfScopeVariables"><span class="hs-identifier hs-var">Opt_DeferOutOfScopeVariables</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079538"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-965"></span><span>
</span><span id="line-966"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-comment">-- Non-empty skolems or givens</span><span>
</span><span id="line-967"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcM Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>   </span><span class="hs-comment">-- Definitely need an implication</span><span>
</span><span id="line-968"></span><span>
</span><span id="line-969"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#alwaysBuildImplication"><span class="hs-identifier hs-type">alwaysBuildImplication</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-970"></span><span class="hs-comment">-- See Note [When to build an implication]</span><span>
</span><span id="line-971"></span><span id="alwaysBuildImplication"><span class="annot"><span class="annottext">alwaysBuildImplication :: SkolemInfo -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#alwaysBuildImplication"><span class="hs-identifier hs-var hs-var">alwaysBuildImplication</span></a></span></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-972"></span><span>
</span><span id="line-973"></span><span class="hs-comment">{-  Commmented out for now while I figure out about error messages.
    See #14185

alwaysBuildImplication (SigSkol ctxt _ _)
  = case ctxt of
      FunSigCtxt {} -&gt; True  -- RHS of a binding with a signature
      _             -&gt; False
alwaysBuildImplication (RuleSkol {})      = True
alwaysBuildImplication (InstSkol {})      = True
alwaysBuildImplication (FamInstSkol {})   = True
alwaysBuildImplication _                  = False
-}</span><span>
</span><span id="line-985"></span><span>
</span><span id="line-986"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#buildImplicationFor"><span class="hs-identifier hs-type">buildImplicationFor</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-987"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-988"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-type">TcEvBinds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-989"></span><span id="buildImplicationFor"><span class="annot"><span class="annottext">buildImplicationFor :: TcLevel
-&gt; SkolemInfo
-&gt; [TcTyVar]
-&gt; [TcTyVar]
-&gt; WantedConstraints
-&gt; TcM (Bag Implication, TcEvBinds)
</span><a href="GHC.Tc.Utils.Unify.html#buildImplicationFor"><span class="hs-identifier hs-var hs-var">buildImplicationFor</span></a></span></span><span> </span><span id="local-6989586621681079531"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079531"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span id="local-6989586621681079530"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079530"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span id="local-6989586621681079529"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079529"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span> </span><span id="local-6989586621681079528"><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079528"><span class="hs-identifier hs-var">given</span></a></span></span><span> </span><span id="local-6989586621681079527"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079527"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-990"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; Bool
</span><a href="GHC.Tc.Types.Constraint.html#isEmptyWC"><span class="hs-identifier hs-var">isEmptyWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079527"><span class="hs-identifier hs-var">wanted</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079528"><span class="hs-identifier hs-var">given</span></a></span><span>
</span><span id="line-991"></span><span>             </span><span class="hs-comment">-- Optimisation : if there are no wanteds, and no givens</span><span>
</span><span id="line-992"></span><span>             </span><span class="hs-comment">-- don't generate an implication at all.</span><span>
</span><span id="line-993"></span><span>             </span><span class="hs-comment">-- Reason for the (null given): we don't want to lose</span><span>
</span><span id="line-994"></span><span>             </span><span class="hs-comment">-- the &quot;inaccessible alternative&quot; error check</span><span>
</span><span id="line-995"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bag Implication, TcEvBinds) -&gt; TcM (Bag Implication, TcEvBinds)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag Implication
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#emptyTcEvBinds"><span class="hs-identifier hs-var">emptyTcEvBinds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-996"></span><span>
</span><span id="line-997"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-998"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">all</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isSkolemTyVar</span><span> </span><span class="hs-operator">&lt;||&gt;</span><span> </span><span class="hs-identifier">isTyVarTyVar</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">skol_tvs</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">skol_tvs</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-999"></span><span>      </span><span class="hs-comment">-- Why allow TyVarTvs? Because implicitly declared kind variables in</span><span>
</span><span id="line-1000"></span><span>      </span><span class="hs-comment">-- non-CUSK type declarations are TyVarTvs, and we need to bring them</span><span>
</span><span id="line-1001"></span><span>      </span><span class="hs-comment">-- into scope as a skolem in an implication. This is OK, though,</span><span>
</span><span id="line-1002"></span><span>      </span><span class="hs-comment">-- because TyVarTvs will always remain tyvars, even after unification.</span><span>
</span><span id="line-1003"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079521"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681079521"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM EvBindsVar
</span><a href="GHC.Tc.Utils.Monad.html#newTcEvBinds"><span class="hs-identifier hs-var">newTcEvBinds</span></a></span><span>
</span><span id="line-1004"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079519"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681079519"><span class="hs-identifier hs-var">implic</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Implication
</span><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier hs-var">newImplication</span></a></span><span>
</span><span id="line-1005"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079518"><span class="annot"><span class="annottext">implic' :: Implication
</span><a href="#local-6989586621681079518"><span class="hs-identifier hs-var hs-var">implic'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681079519"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_tclvl :: TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ic_tclvl"><span class="hs-identifier hs-var">ic_tclvl</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079531"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-1006"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_skols :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079529"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span>
</span><span id="line-1007"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_given :: [TcTyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcTyVar]
</span><a href="#local-6989586621681079528"><span class="hs-identifier hs-var">given</span></a></span><span>
</span><span id="line-1008"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681079527"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-1009"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681079521"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1010"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681079530"><span class="hs-identifier hs-var">skol_info</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1011"></span><span>
</span><span id="line-1012"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Bag Implication, TcEvBinds) -&gt; TcM (Bag Implication, TcEvBinds)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication -&gt; Bag Implication
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681079518"><span class="hs-identifier hs-var">implic'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-var">TcEvBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681079521"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1013"></span><span>
</span><span id="line-1014"></span><span class="hs-comment">{- Note [When to build an implication]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have some 'skolems' and some 'givens', and we are
considering whether to wrap the constraints in their scope into an
implication.  We must /always/ so if either 'skolems' or 'givens' are
non-empty.  But what if both are empty?  You might think we could
always drop the implication.  Other things being equal, the fewer
implications the better.  Less clutter and overhead.  But we must
take care:

* If we have an unsolved [W] g :: a ~# b, and -fdefer-type-errors,
  we'll make a /term-level/ evidence binding for 'g = error &quot;blah&quot;'.
  We must have an EvBindsVar those bindings!, otherwise they end up as
  top-level unlifted bindings, which are verboten. This only matters
  at top level, so we check for that
  See also Note [Deferred errors for coercion holes] in GHC.Tc.Errors.
  cf #14149 for an example of what goes wrong.

* If you have
     f :: Int;  f = f_blah
     g :: Bool; g = g_blah
  If we don't build an implication for f or g (no tyvars, no givens),
  the constraints for f_blah and g_blah are solved together.  And that
  can yield /very/ confusing error messages, because we can get
      [W] C Int b1    -- from f_blah
      [W] C Int b2    -- from g_blan
  and fundpes can yield [D] b1 ~ b2, even though the two functions have
  literally nothing to do with each other.  #14185 is an example.
  Building an implication keeps them separage.
-}</span><span>
</span><span id="line-1044"></span><span>
</span><span id="line-1045"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Boxy unification
*                                                                      *
************************************************************************

The exported functions are all defined as versions of some
non-exported generic functions.
-}</span><span>
</span><span id="line-1055"></span><span>
</span><span id="line-1056"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-type">unifyType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- ^ If present, has type 'ty1'</span><span>
</span><span id="line-1057"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercionN"><span class="hs-identifier hs-type">TcCoercionN</span></a></span><span>
</span><span id="line-1058"></span><span class="hs-comment">-- Actual and expected types</span><span>
</span><span id="line-1059"></span><span class="hs-comment">-- Returns a coercion : ty1 ~ ty2</span><span>
</span><span id="line-1060"></span><span id="unifyType"><span class="annot"><span class="annottext">unifyType :: Maybe (HsExpr GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var hs-var">unifyType</span></a></span></span><span> </span><span id="local-6989586621681079513"><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079513"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span id="local-6989586621681079512"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079512"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079511"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079511"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1061"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#TypeLevel"><span class="hs-identifier hs-var">TypeLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079510"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079512"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079511"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1062"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1063"></span><span>    </span><span id="local-6989586621681079510"><span class="annot"><span class="annottext">origin :: CtOrigin
</span><a href="#local-6989586621681079510"><span class="hs-identifier hs-var hs-var">origin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEqOrigin :: TcType -&gt; TcType -&gt; Maybe SDoc -&gt; Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079512"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1064"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079511"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1065"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_thing :: Maybe SDoc
</span><a href="GHC.Tc.Types.Origin.html#uo_thing"><span class="hs-identifier hs-var">uo_thing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">(HsExpr GhcRn -&gt; SDoc) -&gt; Maybe (HsExpr GhcRn) -&gt; Maybe SDoc
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
</span><a href="#local-6989586621681079513"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-1066"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_visible :: Bool
</span><a href="GHC.Tc.Types.Origin.html#uo_visible"><span class="hs-identifier hs-var">uo_visible</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1067"></span><span>
</span><span id="line-1068"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyTypeET"><span class="hs-identifier hs-type">unifyTypeET</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionN"><span class="hs-identifier hs-type">CoercionN</span></a></span><span>
</span><span id="line-1069"></span><span class="hs-comment">-- Like unifyType, but swap expected and actual in error messages</span><span>
</span><span id="line-1070"></span><span class="hs-comment">-- This is used when typechecking patterns</span><span>
</span><span id="line-1071"></span><span id="unifyTypeET"><span class="annot"><span class="annottext">unifyTypeET :: TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyTypeET"><span class="hs-identifier hs-var hs-var">unifyTypeET</span></a></span></span><span> </span><span id="local-6989586621681079500"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079500"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079499"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079499"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1072"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#TypeLevel"><span class="hs-identifier hs-var">TypeLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079498"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079500"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079499"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1073"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1074"></span><span>    </span><span id="local-6989586621681079498"><span class="annot"><span class="annottext">origin :: CtOrigin
</span><a href="#local-6989586621681079498"><span class="hs-identifier hs-var hs-var">origin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEqOrigin :: TcType -&gt; TcType -&gt; Maybe SDoc -&gt; Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079499"><span class="hs-identifier hs-var">ty2</span></a></span><span>   </span><span class="hs-comment">-- NB swapped</span><span>
</span><span id="line-1075"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079500"><span class="hs-identifier hs-var">ty1</span></a></span><span>   </span><span class="hs-comment">-- NB swapped</span><span>
</span><span id="line-1076"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_thing :: Maybe SDoc
</span><a href="GHC.Tc.Types.Origin.html#uo_thing"><span class="hs-identifier hs-var">uo_thing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SDoc
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1077"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_visible :: Bool
</span><a href="GHC.Tc.Types.Origin.html#uo_visible"><span class="hs-identifier hs-var">uo_visible</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1078"></span><span>
</span><span id="line-1079"></span><span>
</span><span id="line-1080"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyKind"><span class="hs-identifier hs-type">unifyKind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Type.html#HsType"><span class="hs-identifier hs-type">HsType</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionN"><span class="hs-identifier hs-type">CoercionN</span></a></span><span>
</span><span id="line-1081"></span><span id="unifyKind"><span class="annot"><span class="annottext">unifyKind :: Maybe (HsType GhcRn) -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyKind"><span class="hs-identifier hs-var hs-var">unifyKind</span></a></span></span><span> </span><span id="local-6989586621681079496"><span class="annot"><span class="annottext">Maybe (HsType GhcRn)
</span><a href="#local-6989586621681079496"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span id="local-6989586621681079495"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079495"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079494"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079494"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1082"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#KindLevel"><span class="hs-identifier hs-var">KindLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079492"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079495"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079494"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1083"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1084"></span><span>    </span><span id="local-6989586621681079492"><span class="annot"><span class="annottext">origin :: CtOrigin
</span><a href="#local-6989586621681079492"><span class="hs-identifier hs-var hs-var">origin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEqOrigin :: TcType -&gt; TcType -&gt; Maybe SDoc -&gt; Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079495"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1085"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079494"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1086"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_thing :: Maybe SDoc
</span><a href="GHC.Tc.Types.Origin.html#uo_thing"><span class="hs-identifier hs-var">uo_thing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsType GhcRn -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">(HsType GhcRn -&gt; SDoc) -&gt; Maybe (HsType GhcRn) -&gt; Maybe SDoc
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsType GhcRn)
</span><a href="#local-6989586621681079496"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-1087"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_visible :: Bool
</span><a href="GHC.Tc.Types.Origin.html#uo_visible"><span class="hs-identifier hs-var">uo_visible</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1088"></span><span>
</span><span id="line-1089"></span><span>
</span><span id="line-1090"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
                 uType and friends
%*                                                                      *
%************************************************************************

uType is the heart of the unifier.
-}</span><span>
</span><span id="line-1099"></span><span>
</span><span id="line-1100"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-type">uType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#uType_defer"><span class="hs-identifier hs-type">uType_defer</span></a></span><span>
</span><span id="line-1101"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span>
</span><span id="line-1102"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-1103"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>    </span><span class="hs-comment">-- ty1 is the *actual* type</span><span>
</span><span id="line-1104"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>    </span><span class="hs-comment">-- ty2 is the *expected* type</span><span>
</span><span id="line-1105"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionN"><span class="hs-identifier hs-type">CoercionN</span></a></span><span>
</span><span id="line-1106"></span><span>
</span><span id="line-1107"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1108"></span><span class="hs-comment">-- It is always safe to defer unification to the main constraint solver</span><span>
</span><span id="line-1109"></span><span class="hs-comment">-- See Note [Deferred unification]</span><span>
</span><span id="line-1110"></span><span id="uType_defer"><span class="annot"><span class="annottext">uType_defer :: TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType_defer"><span class="hs-identifier hs-var hs-var">uType_defer</span></a></span></span><span> </span><span id="local-6989586621681079482"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079482"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681079481"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079481"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079480"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079480"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079479"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079479"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1111"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079478"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079478"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TypeOrKind -&gt; Role -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEq"><span class="hs-identifier hs-var">emitWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079481"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079482"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079480"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079479"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1112"></span><span>
</span><span id="line-1113"></span><span>       </span><span class="hs-comment">-- Error trace only</span><span>
</span><span id="line-1114"></span><span>       </span><span class="hs-comment">-- NB. do *not* call mkErrInfo unless tracing is on,</span><span>
</span><span id="line-1115"></span><span>       </span><span class="hs-comment">--     because it is hugely expensive (#5631)</span><span>
</span><span id="line-1116"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DumpFlag -&gt; TcRn () -&gt; TcRn ()
forall gbl lcl. DumpFlag -&gt; TcRnIf gbl lcl () -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#whenDOptM"><span class="hs-identifier hs-var">whenDOptM</span></a></span><span> </span><span class="annot"><span class="annottext">DumpFlag
</span><a href="GHC.Driver.Flags.html#Opt_D_dump_tc_trace"><span class="hs-identifier hs-var">Opt_D_dump_tc_trace</span></a></span><span> </span><span class="annot"><span class="annottext">(TcRn () -&gt; TcRn ()) -&gt; TcRn () -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1117"></span><span>            </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079473"><span class="annot"><span class="annottext">[ErrCtxt]
</span><a href="#local-6989586621681079473"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM [ErrCtxt]
</span><a href="GHC.Tc.Utils.Monad.html#getErrCtxt"><span class="hs-identifier hs-var">getErrCtxt</span></a></span><span>
</span><span id="line-1118"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079471"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079471"><span class="hs-identifier hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [ErrCtxt] -&gt; TcM SDoc
</span><a href="GHC.Tc.Utils.Monad.html#mkErrInfo"><span class="hs-identifier hs-var">mkErrInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="GHC.Types.Var.Env.html#emptyTidyEnv"><span class="hs-identifier hs-var">emptyTidyEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[ErrCtxt]
</span><a href="#local-6989586621681079473"><span class="hs-identifier hs-var">ctxt</span></a></span><span>
</span><span id="line-1119"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;utype_defer&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#debugPprType"><span class="hs-identifier hs-var">debugPprType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079480"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1120"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#debugPprType"><span class="hs-identifier hs-var">debugPprType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079479"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1121"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; SDoc
</span><a href="GHC.Tc.Types.Origin.html#pprCtOrigin"><span class="hs-identifier hs-var">pprCtOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079481"><span class="hs-identifier hs-var">origin</span></a></span><span>
</span><span id="line-1122"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681079471"><span class="hs-identifier hs-var">doc</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1123"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;utype_defer2&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079478"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1124"></span><span>            </span><span class="hs-special">}</span><span>
</span><span id="line-1125"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079478"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1126"></span><span>
</span><span id="line-1127"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1128"></span><span id="uType"><span class="annot"><span class="annottext">uType :: TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var hs-var">uType</span></a></span></span><span> </span><span id="local-6989586621681079467"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681079466"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079465"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079465"><span class="hs-identifier hs-var">orig_ty1</span></a></span></span><span> </span><span id="local-6989586621681079464"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079464"><span class="hs-identifier hs-var">orig_ty2</span></a></span></span><span>
</span><span id="line-1129"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079463"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079463"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-1130"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;u_tys&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-1131"></span><span>              </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tclvl&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079463"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-1132"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079465"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;~&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079464"><span class="hs-identifier hs-var">orig_ty2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1133"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; SDoc
</span><a href="GHC.Tc.Types.Origin.html#pprCtOrigin"><span class="hs-identifier hs-var">pprCtOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1134"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079462"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079462"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079465"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079464"><span class="hs-identifier hs-var">orig_ty2</span></a></span><span>
</span><span id="line-1135"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Core.Coercion.html#isReflCo"><span class="hs-identifier hs-var">isReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079462"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1136"></span><span>            </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;u_tys yields no coercion&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">Outputable.empty</span></a></span><span>
</span><span id="line-1137"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;u_tys yields coercion:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079462"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1138"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079462"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1139"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1140"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionN"><span class="hs-identifier hs-type">CoercionN</span></a></span><span>
</span><span id="line-1141"></span><span>        </span><span class="hs-comment">-- The arguments to 'go' are always semantically identical</span><span>
</span><span id="line-1142"></span><span>        </span><span class="hs-comment">-- to orig_ty{1,2} except for looking through type synonyms</span><span>
</span><span id="line-1143"></span><span>
</span><span id="line-1144"></span><span>     </span><span class="hs-comment">-- Unwrap casts before looking for variables. This way, we can easily</span><span>
</span><span id="line-1145"></span><span>     </span><span class="hs-comment">-- recognize (t |&gt; co) ~ (t |&gt; co), which is nice. Previously, we</span><span>
</span><span id="line-1146"></span><span>     </span><span class="hs-comment">-- didn't do it this way, and then the unification above was deferred.</span><span>
</span><span id="line-1147"></span><span>    </span><span id="local-6989586621681079461"><span class="annot"><span class="annottext">go :: TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079461"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681079458"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079458"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681079457"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079457"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079456"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079456"><span class="hs-identifier hs-var">t2</span></a></span></span><span>
</span><span id="line-1148"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079455"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079455"><span class="hs-identifier hs-var">co_tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079458"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079456"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1149"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoherenceLeftCo"><span class="hs-identifier hs-var">mkCoherenceLeftCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079458"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079457"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079455"><span class="hs-identifier hs-var">co_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1150"></span><span>
</span><span id="line-1151"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079453"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079453"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681079452"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079452"><span class="hs-identifier hs-var">t2</span></a></span></span><span> </span><span id="local-6989586621681079451"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079451"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1152"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079450"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079450"><span class="hs-identifier hs-var">co_tys</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079453"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079452"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1153"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TcType -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoherenceRightCo"><span class="hs-identifier hs-var">mkCoherenceRightCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079452"><span class="hs-identifier hs-var">t2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079451"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079450"><span class="hs-identifier hs-var">co_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1154"></span><span>
</span><span id="line-1155"></span><span>        </span><span class="hs-comment">-- Variables; go for uUnfilledVar</span><span>
</span><span id="line-1156"></span><span>        </span><span class="hs-comment">-- Note that we pass in *original* (before synonym expansion),</span><span>
</span><span id="line-1157"></span><span>        </span><span class="hs-comment">-- so that type variables tend to get filled in with</span><span>
</span><span id="line-1158"></span><span>        </span><span class="hs-comment">-- the most informative version of the type</span><span>
</span><span id="line-1159"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079448"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079448"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079447"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079447"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1160"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079446"><span class="annot"><span class="annottext">LookupTyVarResult
</span><a href="#local-6989586621681079446"><span class="hs-identifier hs-var">lookup_res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM LookupTyVarResult
</span><a href="GHC.Tc.Utils.Unify.html#lookupTcTyVar"><span class="hs-identifier hs-var">lookupTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079448"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1161"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">LookupTyVarResult
</span><a href="#local-6989586621681079446"><span class="hs-identifier hs-var">lookup_res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1162"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#Filled"><span class="hs-identifier hs-type">Filled</span></a></span><span> </span><span id="local-6989586621681079443"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079443"><span class="hs-identifier hs-var">ty1</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;found filled tyvar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079448"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:-&gt;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079443"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1163"></span><span>                                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079443"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079447"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1164"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#Unfilled"><span class="hs-identifier hs-type">Unfilled</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar"><span class="hs-identifier hs-var">uUnfilledVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#NotSwapped"><span class="hs-identifier hs-var">NotSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079448"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079447"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1165"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079439"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079439"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079438"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079438"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1166"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079437"><span class="annot"><span class="annottext">LookupTyVarResult
</span><a href="#local-6989586621681079437"><span class="hs-identifier hs-var">lookup_res</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM LookupTyVarResult
</span><a href="GHC.Tc.Utils.Unify.html#lookupTcTyVar"><span class="hs-identifier hs-var">lookupTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079438"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1167"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">LookupTyVarResult
</span><a href="#local-6989586621681079437"><span class="hs-identifier hs-var">lookup_res</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1168"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#Filled"><span class="hs-identifier hs-type">Filled</span></a></span><span> </span><span id="local-6989586621681079436"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079436"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;found filled tyvar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079438"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:-&gt;&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079436"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1169"></span><span>                                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079439"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079436"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1170"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#Unfilled"><span class="hs-identifier hs-type">Unfilled</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar"><span class="hs-identifier hs-var">uUnfilledVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="GHC.Types.Basic.html#IsSwapped"><span class="hs-identifier hs-var">IsSwapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079438"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079439"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1171"></span><span>
</span><span id="line-1172"></span><span>      </span><span class="hs-comment">-- See Note [Expanding synonyms during unification]</span><span>
</span><span id="line-1173"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079434"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681079434"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079433"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079433"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079432"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079432"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1174"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079433"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079432"><span class="hs-identifier hs-var">tc2</span></a></span><span>
</span><span id="line-1175"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079434"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-1176"></span><span>
</span><span id="line-1177"></span><span>        </span><span class="hs-comment">-- See Note [Expanding synonyms during unification]</span><span>
</span><span id="line-1178"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-1179"></span><span>        </span><span class="hs-comment">-- Also NB that we recurse to 'go' so that we don't push a</span><span>
</span><span id="line-1180"></span><span>        </span><span class="hs-comment">-- new item on the origin stack. As a result if we have</span><span>
</span><span id="line-1181"></span><span>        </span><span class="hs-comment">--   type Foo = Int</span><span>
</span><span id="line-1182"></span><span>        </span><span class="hs-comment">-- and we try to unify  Foo ~ Bool</span><span>
</span><span id="line-1183"></span><span>        </span><span class="hs-comment">-- we'll end up saying &quot;can't match Foo with Bool&quot;</span><span>
</span><span id="line-1184"></span><span>        </span><span class="hs-comment">-- rather than &quot;can't match &quot;Int with Bool&quot;.  See #4535.</span><span>
</span><span id="line-1185"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079430"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079430"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079429"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079429"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1186"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079428"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079428"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079430"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079428"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079429"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1187"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079427"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079427"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079429"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079430"><span class="hs-identifier hs-var">ty1</span></a></span><span>  </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079427"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-1188"></span><span>
</span><span id="line-1189"></span><span>        </span><span class="hs-comment">-- Functions (or predicate functions) just check the two parts</span><span>
</span><span id="line-1190"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681079426"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079426"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span id="local-6989586621681079425"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079425"><span class="hs-identifier hs-var">fun1</span></a></span></span><span> </span><span id="local-6989586621681079424"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079424"><span class="hs-identifier hs-var">arg1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681079423"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079423"><span class="hs-identifier hs-var">w2</span></a></span></span><span> </span><span id="local-6989586621681079422"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079422"><span class="hs-identifier hs-var">fun2</span></a></span></span><span> </span><span id="local-6989586621681079421"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079421"><span class="hs-identifier hs-var">arg2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1191"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079420"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079420"><span class="hs-identifier hs-var">co_l</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079425"><span class="hs-identifier hs-var">fun1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079422"><span class="hs-identifier hs-var">fun2</span></a></span><span>
</span><span id="line-1192"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079419"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079419"><span class="hs-identifier hs-var">co_r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079424"><span class="hs-identifier hs-var">arg1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079421"><span class="hs-identifier hs-var">arg2</span></a></span><span>
</span><span id="line-1193"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079418"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079418"><span class="hs-identifier hs-var">co_w</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079426"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079423"><span class="hs-identifier hs-var">w2</span></a></span><span>
</span><span id="line-1194"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; Coercion -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkFunCo"><span class="hs-identifier hs-var">mkFunCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079418"><span class="hs-identifier hs-var">co_w</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079420"><span class="hs-identifier hs-var">co_l</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079419"><span class="hs-identifier hs-var">co_r</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1195"></span><span>
</span><span id="line-1196"></span><span>        </span><span class="hs-comment">-- Always defer if a type synonym family (type function)</span><span>
</span><span id="line-1197"></span><span>        </span><span class="hs-comment">-- is involved.  (Data families behave rigidly.)</span><span>
</span><span id="line-1198"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079416"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681079416"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079415"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079415"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079414"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079414"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1199"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeFamilyTyCon"><span class="hs-identifier hs-var">isTypeFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079415"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079412"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079416"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079414"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1200"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079411"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079411"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079410"><span class="annot"><span class="annottext">ty2 :: TcType
</span><a href="#local-6989586621681079410"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079409"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079409"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-1201"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeFamilyTyCon"><span class="hs-identifier hs-var">isTypeFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079409"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079412"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079411"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079410"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1202"></span><span>
</span><span id="line-1203"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079408"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079408"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621681079407"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079407"><span class="hs-identifier hs-var">tys1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079406"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079406"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621681079405"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079405"><span class="hs-identifier hs-var">tys2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1204"></span><span>      </span><span class="hs-comment">-- See Note [Mismatched type lists and application decomposition]</span><span>
</span><span id="line-1205"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079408"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyCon -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079406"><span class="hs-identifier hs-var">tc2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; ThetaType -&gt; Bool
forall a b. [a] -&gt; [b] -&gt; Bool
</span><a href="GHC.Utils.Misc.html#equalLength"><span class="hs-identifier hs-var">equalLength</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079407"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079405"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1206"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isGenerativeTyCon</span><span> </span><span class="hs-identifier">tc1</span><span> </span><span class="hs-identifier">Nominal</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tc1</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1207"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079402"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681079402"><span class="hs-identifier hs-var">cos</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion)
-&gt; [CtOrigin]
-&gt; ThetaType
-&gt; ThetaType
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [Coercion]
forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; b -&gt; c -&gt; m d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; m [d]
</span><a href="GHC.Utils.Monad.html#zipWith3M"><span class="hs-identifier hs-var">zipWith3M</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CtOrigin]
</span><a href="#local-6989586621681079400"><span class="hs-identifier hs-var">origins'</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079407"><span class="hs-identifier hs-var">tys1</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079405"><span class="hs-identifier hs-var">tys2</span></a></span><span>
</span><span id="line-1208"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTyConAppCo"><span class="hs-identifier hs-var">mkTyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079408"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681079402"><span class="hs-identifier hs-var">cos</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1209"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1210"></span><span>        </span><span id="local-6989586621681079400"><span class="annot"><span class="annottext">origins' :: [CtOrigin]
</span><a href="#local-6989586621681079400"><span class="hs-identifier hs-var hs-var">origins'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; CtOrigin) -&gt; [Bool] -&gt; [CtOrigin]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681079398"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079398"><span class="hs-identifier hs-var">is_vis</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079398"><span class="hs-identifier hs-var">is_vis</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#toInvisibleOrigin"><span class="hs-identifier hs-var">toInvisibleOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1211"></span><span>                       </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [Bool]
</span><a href="GHC.Tc.Utils.TcType.html#tcTyConVisibilities"><span class="hs-identifier hs-var">tcTyConVisibilities</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079408"><span class="hs-identifier hs-var">tc1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1212"></span><span>
</span><span id="line-1213"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621681079394"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681079394"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079393"><span class="annot"><span class="annottext">ty :: TcType
</span><a href="#local-6989586621681079393"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span id="local-6989586621681079392"><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681079392"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1214"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681079394"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">TyLit -&gt; TyLit -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TyLit
</span><a href="#local-6989586621681079392"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1215"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079393"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1216"></span><span>
</span><span id="line-1217"></span><span>        </span><span class="hs-comment">-- See Note [Care with type applications]</span><span>
</span><span id="line-1218"></span><span>        </span><span class="hs-comment">-- Do not decompose FunTy against App;</span><span>
</span><span id="line-1219"></span><span>        </span><span class="hs-comment">-- it's often a type error, so leave it for the constraint solver</span><span>
</span><span id="line-1220"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681079390"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079390"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621681079389"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079389"><span class="hs-identifier hs-var">t1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681079388"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079388"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span id="local-6989586621681079387"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079387"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1221"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079386"><span class="hs-identifier hs-var">go_app</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isNextArgVisible"><span class="hs-identifier hs-var">isNextArgVisible</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079390"><span class="hs-identifier hs-var">s1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079390"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079389"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079388"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079387"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1222"></span><span>
</span><span id="line-1223"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681079384"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079384"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621681079383"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079383"><span class="hs-identifier hs-var">t1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079382"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079382"><span class="hs-identifier hs-var">tc2</span></a></span></span><span> </span><span id="local-6989586621681079381"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079381"><span class="hs-identifier hs-var">ts2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1224"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079380"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079380"><span class="hs-identifier hs-var">ts2'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079379"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079379"><span class="hs-identifier hs-var">t2'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Maybe (ThetaType, TcType)
forall a. [a] -&gt; Maybe ([a], a)
</span><a href="GHC.Utils.Misc.html#snocView"><span class="hs-identifier hs-var">snocView</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079381"><span class="hs-identifier hs-var">ts2</span></a></span><span>
</span><span id="line-1225"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">mustBeSaturated</span><span> </span><span class="hs-identifier">tc2</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1226"></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079386"><span class="hs-identifier hs-var">go_app</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; ThetaType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isNextTyConArgVisible"><span class="hs-identifier hs-var">isNextTyConArgVisible</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079382"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079380"><span class="hs-identifier hs-var">ts2'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079384"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079383"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; ThetaType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-var">TyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079382"><span class="hs-identifier hs-var">tc2</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079380"><span class="hs-identifier hs-var">ts2'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079379"><span class="hs-identifier hs-var">t2'</span></a></span><span>
</span><span id="line-1227"></span><span>
</span><span id="line-1228"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079375"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079375"><span class="hs-identifier hs-var">tc1</span></a></span></span><span> </span><span id="local-6989586621681079374"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079374"><span class="hs-identifier hs-var">ts1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681079373"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079373"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span id="local-6989586621681079372"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079372"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1229"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079371"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079371"><span class="hs-identifier hs-var">ts1'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681079370"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079370"><span class="hs-identifier hs-var">t1'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Maybe (ThetaType, TcType)
forall a. [a] -&gt; Maybe ([a], a)
</span><a href="GHC.Utils.Misc.html#snocView"><span class="hs-identifier hs-var">snocView</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079374"><span class="hs-identifier hs-var">ts1</span></a></span><span>
</span><span id="line-1230"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">mustBeSaturated</span><span> </span><span class="hs-identifier">tc1</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1231"></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079386"><span class="hs-identifier hs-var">go_app</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; ThetaType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isNextTyConArgVisible"><span class="hs-identifier hs-var">isNextTyConArgVisible</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079375"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079371"><span class="hs-identifier hs-var">ts1'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; ThetaType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-var">TyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079375"><span class="hs-identifier hs-var">tc1</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079371"><span class="hs-identifier hs-var">ts1'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079370"><span class="hs-identifier hs-var">t1'</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079373"><span class="hs-identifier hs-var">s2</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079372"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1232"></span><span>
</span><span id="line-1233"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621681079368"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079368"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621681079367"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079367"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1234"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079366"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681079366"><span class="hs-identifier hs-var hs-var">ty1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcType
</span><a href="GHC.Core.Coercion.html#coercionType"><span class="hs-identifier hs-var">coercionType</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079368"><span class="hs-identifier hs-var">co1</span></a></span><span>
</span><span id="line-1235"></span><span>                 </span><span id="local-6989586621681079364"><span class="annot"><span class="annottext">ty2 :: TcType
</span><a href="#local-6989586621681079364"><span class="hs-identifier hs-var hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcType
</span><a href="GHC.Core.Coercion.html#coercionType"><span class="hs-identifier hs-var">coercionType</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079367"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-1236"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079363"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079363"><span class="hs-identifier hs-var">kco</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#KindLevel"><span class="hs-identifier hs-var">KindLevel</span></a></span><span>
</span><span id="line-1237"></span><span>                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType -&gt; CtOrigin -&gt; Maybe TypeOrKind -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#KindEqOrigin"><span class="hs-identifier hs-var">KindEqOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079465"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079464"><span class="hs-identifier hs-var">orig_ty2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span>
</span><span id="line-1238"></span><span>                                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeOrKind -&gt; Maybe TypeOrKind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1239"></span><span>                          </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079366"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079364"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1240"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; Coercion -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkProofIrrelCo"><span class="hs-identifier hs-var">mkProofIrrelCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079363"><span class="hs-identifier hs-var">kco</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079368"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079367"><span class="hs-identifier hs-var">co2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1241"></span><span>
</span><span id="line-1242"></span><span>        </span><span class="hs-comment">-- Anything else fails</span><span>
</span><span id="line-1243"></span><span>        </span><span class="hs-comment">-- E.g. unifying for-all types, which is relative unusual</span><span>
</span><span id="line-1244"></span><span>    </span><span class="annot"><a href="#local-6989586621681079461"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079360"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079360"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079359"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079359"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079412"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079360"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079359"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1245"></span><span>
</span><span id="line-1246"></span><span>    </span><span class="hs-comment">------------------</span><span>
</span><span id="line-1247"></span><span>    </span><span id="local-6989586621681079412"><span class="annot"><span class="annottext">defer :: TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079412"><span class="hs-identifier hs-var hs-var">defer</span></a></span></span><span> </span><span id="local-6989586621681079356"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079356"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681079355"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079355"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>   </span><span class="hs-comment">-- See Note [Check for equality before deferring]</span><span>
</span><span id="line-1248"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079356"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType -&gt; Bool
TcType -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-operator hs-var">`tcEqType`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079355"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079356"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1249"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType_defer"><span class="hs-identifier hs-var">uType_defer</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079356"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079355"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1250"></span><span>
</span><span id="line-1251"></span><span>    </span><span class="hs-comment">------------------</span><span>
</span><span id="line-1252"></span><span>    </span><span id="local-6989586621681079386"><span class="annot"><span class="annottext">go_app :: Bool -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079386"><span class="hs-identifier hs-var hs-var">go_app</span></a></span></span><span> </span><span id="local-6989586621681079350"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079350"><span class="hs-identifier hs-var">vis</span></a></span></span><span> </span><span id="local-6989586621681079349"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079349"><span class="hs-identifier hs-var">s1</span></a></span></span><span> </span><span id="local-6989586621681079348"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079348"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681079347"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079347"><span class="hs-identifier hs-var">s2</span></a></span></span><span> </span><span id="local-6989586621681079346"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079346"><span class="hs-identifier hs-var">t2</span></a></span></span><span>
</span><span id="line-1253"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079345"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079345"><span class="hs-identifier hs-var">co_s</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079349"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079347"><span class="hs-identifier hs-var">s2</span></a></span><span>
</span><span id="line-1254"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079344"><span class="annot"><span class="annottext">arg_origin :: CtOrigin
</span><a href="#local-6989586621681079344"><span class="hs-identifier hs-var hs-var">arg_origin</span></a></span></span><span>
</span><span id="line-1255"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079350"><span class="hs-identifier hs-var">vis</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span>
</span><span id="line-1256"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#toInvisibleOrigin"><span class="hs-identifier hs-var">toInvisibleOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079466"><span class="hs-identifier hs-var">origin</span></a></span><span>
</span><span id="line-1257"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079343"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079343"><span class="hs-identifier hs-var">co_t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079467"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079344"><span class="hs-identifier hs-var">arg_origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079348"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079346"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1258"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkAppCo"><span class="hs-identifier hs-var">mkAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079345"><span class="hs-identifier hs-var">co_s</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079343"><span class="hs-identifier hs-var">co_t</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1259"></span><span>
</span><span id="line-1260"></span><span class="hs-comment">{- Note [Check for equality before deferring]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Particularly in ambiguity checks we can get equalities like (ty ~ ty).
If ty involves a type function we may defer, which isn't very sensible.
An egregious example of this was in test T9872a, which has a type signature
       Proxy :: Proxy (Solutions Cubes)
Doing the ambiguity check on this signature generates the equality
   Solutions Cubes ~ Solutions Cubes
and currently the constraint solver normalises both sides at vast cost.
This little short-cut in 'defer' helps quite a bit.

Note [Care with type applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: type applications need a bit of care!
They can match FunTy and TyConApp, so use splitAppTy_maybe
NB: we've already dealt with type variables and Notes,
so if one type is an App the other one jolly well better be too

Note [Mismatched type lists and application decomposition]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we find two TyConApps, you might think that the argument lists
are guaranteed equal length.  But they aren't. Consider matching
        w (T x) ~ Foo (T x y)
We do match (w ~ Foo) first, but in some circumstances we simply create
a deferred constraint; and then go ahead and match (T x ~ T x y).
This came up in #3950.

So either
   (a) either we must check for identical argument kinds
       when decomposing applications,

   (b) or we must be prepared for ill-kinded unification sub-problems

Currently we adopt (b) since it seems more robust -- no need to maintain
a global invariant.

Note [Expanding synonyms during unification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We expand synonyms during unification, but:
 * We expand *after* the variable case so that we tend to unify
   variables with un-expanded type synonym. This just makes it
   more likely that the inferred types will mention type synonyms
   understandable to the user

 * Similarly, we expand *after* the CastTy case, just in case the
   CastTy wraps a variable.

 * We expand *before* the TyConApp case.  For example, if we have
      type Phantom a = Int
   and are unifying
      Phantom Int ~ Phantom Char
   it is *wrong* to unify Int and Char.

 * The problem case immediately above can happen only with arguments
   to the tycon. So we check for nullary tycons *before* expanding.
   This is particularly helpful when checking (* ~ *), because * is
   now a type synonym.

Note [Deferred Unification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
We may encounter a unification ty1 ~ ty2 that cannot be performed syntactically,
and yet its consistency is undetermined. Previously, there was no way to still
make it consistent. So a mismatch error was issued.

Now these unifications are deferred until constraint simplification, where type
family instances and given equations may (or may not) establish the consistency.
Deferred unifications are of the form
                F ... ~ ...
or              x ~ ...
where F is a type function and x is a type variable.
E.g.
        id :: x ~ y =&gt; x -&gt; y
        id e = e

involves the unification x = y. It is deferred until we bring into account the
context x ~ y to establish that it holds.

If available, we defer original types (rather than those where closed type
synonyms have already been expanded via tcCoreView).  This is, as usual, to
improve error messages.


************************************************************************
*                                                                      *
                 uUnfilledVar and friends
*                                                                      *
************************************************************************

@uunfilledVar@ is called when at least one of the types being unified is a
variable.  It does {\em not} assume that the variable is a fixed point
of the substitution; rather, notice that @uVar@ (defined below) nips
back into @uTys@ if it turns out that the variable is already bound.
-}</span><span>
</span><span id="line-1353"></span><span>
</span><span id="line-1354"></span><span class="hs-comment">----------</span><span>
</span><span id="line-1355"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar"><span class="hs-identifier hs-type">uUnfilledVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-1356"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span>
</span><span id="line-1357"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-1358"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>        </span><span class="hs-comment">-- Tyvar 1: not necessarily a meta-tyvar</span><span>
</span><span id="line-1359"></span><span>                               </span><span class="hs-comment">--    definitely not a /filled/ meta-tyvar</span><span>
</span><span id="line-1360"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span>      </span><span class="hs-comment">-- Type 2</span><span>
</span><span id="line-1361"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-1362"></span><span class="hs-comment">-- &quot;Unfilled&quot; means that the variable is definitely not a filled-in meta tyvar</span><span>
</span><span id="line-1363"></span><span class="hs-comment">--            It might be a skolem, or untouchable, or meta</span><span>
</span><span id="line-1364"></span><span>
</span><span id="line-1365"></span><span id="uUnfilledVar"><span class="annot"><span class="annottext">uUnfilledVar :: CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar"><span class="hs-identifier hs-var hs-var">uUnfilledVar</span></a></span></span><span> </span><span id="local-6989586621681079341"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079341"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079340"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079340"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681079339"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079339"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681079338"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079338"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681079337"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079337"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1366"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079336"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079336"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079337"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1367"></span><span>             </span><span class="hs-comment">-- Zonk to expose things to the</span><span>
</span><span id="line-1368"></span><span>             </span><span class="hs-comment">-- occurs check, and so that if ty2</span><span>
</span><span id="line-1369"></span><span>             </span><span class="hs-comment">-- looks like a type variable then it</span><span>
</span><span id="line-1370"></span><span>             </span><span class="hs-comment">-- /is/ a type variable</span><span>
</span><span id="line-1371"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar1"><span class="hs-identifier hs-var">uUnfilledVar1</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079341"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079340"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079339"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079338"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079336"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1372"></span><span>
</span><span id="line-1373"></span><span class="hs-comment">----------</span><span>
</span><span id="line-1374"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar1"><span class="hs-identifier hs-type">uUnfilledVar1</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-1375"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span>
</span><span id="line-1376"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-1377"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>        </span><span class="hs-comment">-- Tyvar 1: not necessarily a meta-tyvar</span><span>
</span><span id="line-1378"></span><span>                                </span><span class="hs-comment">--    definitely not a /filled/ meta-tyvar</span><span>
</span><span id="line-1379"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span>      </span><span class="hs-comment">-- Type 2, zonked</span><span>
</span><span id="line-1380"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-1381"></span><span id="uUnfilledVar1"><span class="annot"><span class="annottext">uUnfilledVar1 :: CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar1"><span class="hs-identifier hs-var hs-var">uUnfilledVar1</span></a></span></span><span> </span><span id="local-6989586621681079333"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079333"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079332"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079332"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681079331"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079331"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681079330"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079330"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681079329"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079329"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1382"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079328"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079328"><span class="hs-identifier hs-var">tv2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcTyVar
</span><a href="GHC.Tc.Utils.TcType.html#tcGetTyVar_maybe"><span class="hs-identifier hs-var">tcGetTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079329"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1383"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM Coercion
</span><a href="#local-6989586621681079326"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079328"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1384"></span><span>
</span><span id="line-1385"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1386"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar2"><span class="hs-identifier hs-var">uUnfilledVar2</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079333"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079332"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079331"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079330"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079329"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1387"></span><span>
</span><span id="line-1388"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1389"></span><span>    </span><span class="hs-comment">-- 'go' handles the case where both are</span><span>
</span><span id="line-1390"></span><span>    </span><span class="hs-comment">-- tyvars so we might want to swap</span><span>
</span><span id="line-1391"></span><span>    </span><span class="hs-comment">-- E.g. maybe tv2 is a meta-tyvar and tv1 is not</span><span>
</span><span id="line-1392"></span><span>    </span><span id="local-6989586621681079326"><span class="annot"><span class="annottext">go :: TcTyVar -&gt; TcM Coercion
</span><a href="#local-6989586621681079326"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681079321"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079321"><span class="hs-identifier hs-var">tv2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079330"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079321"><span class="hs-identifier hs-var">tv2</span></a></span><span>  </span><span class="hs-comment">-- Same type variable =&gt; no-op</span><span>
</span><span id="line-1393"></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079330"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1394"></span><span>
</span><span id="line-1395"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcTyVar -&gt; TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#swapOverTyVars"><span class="hs-identifier hs-var">swapOverTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079330"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079321"><span class="hs-identifier hs-var">tv2</span></a></span><span>   </span><span class="hs-comment">-- Distinct type variables</span><span>
</span><span id="line-1396"></span><span>               </span><span class="hs-comment">-- Swap meta tyvar to the left if poss</span><span>
</span><span id="line-1397"></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079319"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079319"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM TcTyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079330"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1398"></span><span>                     </span><span class="hs-comment">-- We must zonk tv1's kind because that might</span><span>
</span><span id="line-1399"></span><span>                     </span><span class="hs-comment">-- not have happened yet, and it's an invariant of</span><span>
</span><span id="line-1400"></span><span>                     </span><span class="hs-comment">-- uUnfilledTyVar2 that ty2 is fully zonked</span><span>
</span><span id="line-1401"></span><span>                     </span><span class="hs-comment">-- Omitting this caused #16902</span><span>
</span><span id="line-1402"></span><span>                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar2"><span class="hs-identifier hs-var">uUnfilledVar2</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079333"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079332"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SwapFlag -&gt; SwapFlag
</span><a href="GHC.Types.Basic.html#flipSwap"><span class="hs-identifier hs-var">flipSwap</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079331"><span class="hs-identifier hs-var">swapped</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1403"></span><span>                           </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079321"><span class="hs-identifier hs-var">tv2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079319"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1404"></span><span>
</span><span id="line-1405"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1406"></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar2"><span class="hs-identifier hs-var">uUnfilledVar2</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079333"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079332"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079331"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079330"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079329"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1407"></span><span>
</span><span id="line-1408"></span><span class="hs-comment">----------</span><span>
</span><span id="line-1409"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar2"><span class="hs-identifier hs-type">uUnfilledVar2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-1410"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span>
</span><span id="line-1411"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SwapFlag"><span class="hs-identifier hs-type">SwapFlag</span></a></span><span>
</span><span id="line-1412"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>        </span><span class="hs-comment">-- Tyvar 1: not necessarily a meta-tyvar</span><span>
</span><span id="line-1413"></span><span>                                </span><span class="hs-comment">--    definitely not a /filled/ meta-tyvar</span><span>
</span><span id="line-1414"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier hs-type">TcTauType</span></a></span><span>      </span><span class="hs-comment">-- Type 2, zonked</span><span>
</span><span id="line-1415"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-1416"></span><span id="uUnfilledVar2"><span class="annot"><span class="annottext">uUnfilledVar2 :: CtOrigin
-&gt; TypeOrKind -&gt; SwapFlag -&gt; TcTyVar -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uUnfilledVar2"><span class="hs-identifier hs-var hs-var">uUnfilledVar2</span></a></span></span><span> </span><span id="local-6989586621681079316"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079316"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681079315"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079315"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681079314"><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079314"><span class="hs-identifier hs-var">swapped</span></a></span></span><span> </span><span id="local-6989586621681079313"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681079312"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-1417"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079311"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079311"><span class="hs-identifier hs-var">dflags</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1418"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079310"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079310"><span class="hs-identifier hs-var">cur_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-1419"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; TcLevel -&gt; TcM Coercion
</span><a href="#local-6989586621681079309"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079311"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079310"><span class="hs-identifier hs-var">cur_lvl</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1420"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1421"></span><span>    </span><span id="local-6989586621681079309"><span class="annot"><span class="annottext">go :: DynFlags -&gt; TcLevel -&gt; TcM Coercion
</span><a href="#local-6989586621681079309"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681079292"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079292"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681079291"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079291"><span class="hs-identifier hs-var">cur_lvl</span></a></span></span><span>
</span><span id="line-1422"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcTyVar -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#canSolveByUnification"><span class="hs-identifier hs-var">canSolveByUnification</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079291"><span class="hs-identifier hs-var">cur_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1423"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-type">MTVU_OK</span></a></span><span> </span><span id="local-6989586621681079289"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079289"><span class="hs-identifier hs-var">ty2'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; TcTyVar -&gt; TcType -&gt; MetaTyVarUpdateResult TcType
</span><a href="GHC.Tc.Utils.Unify.html#metaTyVarUpdateOK"><span class="hs-identifier hs-var">metaTyVarUpdateOK</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079292"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1424"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079288"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079288"><span class="hs-identifier hs-var">co_k</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#KindLevel"><span class="hs-identifier hs-var">KindLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079287"><span class="hs-identifier hs-var">kind_origin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079289"><span class="hs-identifier hs-var">ty2'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1425"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;uUnfilledVar2 ok&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1426"></span><span>             </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1427"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TcType -&gt; TcType
TcType -&gt; TcType
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span>  </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1428"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#isTcReflCo"><span class="hs-identifier hs-var">isTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079288"><span class="hs-identifier hs-var">co_k</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079288"><span class="hs-identifier hs-var">co_k</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1429"></span><span>
</span><span id="line-1430"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Tc.Types.Evidence.html#isTcReflCo"><span class="hs-identifier hs-var">isTcReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079288"><span class="hs-identifier hs-var">co_k</span></a></span><span>
</span><span id="line-1431"></span><span>               </span><span class="hs-comment">-- Only proceed if the kinds match</span><span>
</span><span id="line-1432"></span><span>               </span><span class="hs-comment">-- NB: tv1 should still be unfilled, despite the kind unification</span><span>
</span><span id="line-1433"></span><span>               </span><span class="hs-comment">--     because tv1 is not free in ty2 (or, hence, in its kind)</span><span>
</span><span id="line-1434"></span><span>             </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-var">writeMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079289"><span class="hs-identifier hs-var">ty2'</span></a></span><span>
</span><span id="line-1435"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcNomReflCo"><span class="hs-identifier hs-var">mkTcNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079289"><span class="hs-identifier hs-var">ty2'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1436"></span><span>
</span><span id="line-1437"></span><span>             </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">TcM Coercion
</span><a href="#local-6989586621681079282"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-comment">-- This cannot be solved now.  See GHC.Tc.Solver.Canonical</span><span>
</span><span id="line-1438"></span><span>                          </span><span class="hs-comment">-- Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-1439"></span><span>
</span><span id="line-1440"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1441"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;uUnfilledVar2 not ok&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1442"></span><span>               </span><span class="hs-comment">-- Occurs check or an untouchable: just defer</span><span>
</span><span id="line-1443"></span><span>               </span><span class="hs-comment">-- NB: occurs check isn't necessarily fatal:</span><span>
</span><span id="line-1444"></span><span>               </span><span class="hs-comment">--     eg tv1 occurred in type family parameter</span><span>
</span><span id="line-1445"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcM Coercion
</span><a href="#local-6989586621681079282"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1446"></span><span>
</span><span id="line-1447"></span><span>    </span><span id="local-6989586621681079281"><span class="annot"><span class="annottext">ty1 :: TcType
</span><a href="#local-6989586621681079281"><span class="hs-identifier hs-var hs-var">ty1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079313"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1448"></span><span>    </span><span id="local-6989586621681079287"><span class="annot"><span class="annottext">kind_origin :: CtOrigin
</span><a href="#local-6989586621681079287"><span class="hs-identifier hs-var hs-var">kind_origin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType -&gt; CtOrigin -&gt; Maybe TypeOrKind -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#KindEqOrigin"><span class="hs-identifier hs-var">KindEqOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079281"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079316"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeOrKind -&gt; Maybe TypeOrKind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079315"><span class="hs-identifier hs-var">t_or_k</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1449"></span><span>
</span><span id="line-1450"></span><span>    </span><span id="local-6989586621681079282"><span class="annot"><span class="annottext">defer :: TcM Coercion
</span><a href="#local-6989586621681079282"><span class="hs-identifier hs-var hs-var">defer</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SwapFlag
-&gt; (TcType -&gt; TcType -&gt; TcM Coercion)
-&gt; TcType
-&gt; TcType
-&gt; TcM Coercion
forall a b. SwapFlag -&gt; (a -&gt; a -&gt; b) -&gt; a -&gt; a -&gt; b
</span><a href="GHC.Types.Basic.html#unSwap"><span class="hs-identifier hs-var">unSwap</span></a></span><span> </span><span class="annot"><span class="annottext">SwapFlag
</span><a href="#local-6989586621681079314"><span class="hs-identifier hs-var">swapped</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType_defer"><span class="hs-identifier hs-var">uType_defer</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681079315"><span class="hs-identifier hs-var">t_or_k</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079316"><span class="hs-identifier hs-var">origin</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079281"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079312"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-1451"></span><span>
</span><span id="line-1452"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#swapOverTyVars"><span class="hs-identifier hs-type">swapOverTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1453"></span><span id="swapOverTyVars"><span class="annot"><span class="annottext">swapOverTyVars :: Bool -&gt; TcTyVar -&gt; TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#swapOverTyVars"><span class="hs-identifier hs-var hs-var">swapOverTyVars</span></a></span></span><span> </span><span id="local-6989586621681079279"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079279"><span class="hs-identifier hs-var">is_given</span></a></span></span><span> </span><span id="local-6989586621681079278"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079278"><span class="hs-identifier hs-var">tv1</span></a></span></span><span> </span><span id="local-6989586621681079277"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079277"><span class="hs-identifier hs-var">tv2</span></a></span></span><span>
</span><span id="line-1454"></span><span>  </span><span class="hs-comment">-- See Note [Unification variables on the left]</span><span>
</span><span id="line-1455"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079279"><span class="hs-identifier hs-var">is_given</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079276"><span class="hs-identifier hs-var">pri1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079275"><span class="hs-identifier hs-var">pri2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1456"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079279"><span class="hs-identifier hs-var">is_given</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079275"><span class="hs-identifier hs-var">pri2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079276"><span class="hs-identifier hs-var">pri1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1457"></span><span>
</span><span id="line-1458"></span><span>  </span><span class="hs-comment">-- Level comparison: see Note [TyVar/TyVar orientation]</span><span>
</span><span id="line-1459"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079273"><span class="hs-identifier hs-var">lvl1</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#strictlyDeeperThan"><span class="hs-operator hs-var">`strictlyDeeperThan`</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079271"><span class="hs-identifier hs-var">lvl2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1460"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079271"><span class="hs-identifier hs-var">lvl2</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#strictlyDeeperThan"><span class="hs-operator hs-var">`strictlyDeeperThan`</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079273"><span class="hs-identifier hs-var">lvl1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1461"></span><span>
</span><span id="line-1462"></span><span>  </span><span class="hs-comment">-- Priority: see Note [TyVar/TyVar orientation]</span><span>
</span><span id="line-1463"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079276"><span class="hs-identifier hs-var">pri1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079275"><span class="hs-identifier hs-var">pri2</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1464"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079275"><span class="hs-identifier hs-var">pri2</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079276"><span class="hs-identifier hs-var">pri1</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1465"></span><span>
</span><span id="line-1466"></span><span>  </span><span class="hs-comment">-- Names: see Note [TyVar/TyVar orientation]</span><span>
</span><span id="line-1467"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isSystemName"><span class="hs-identifier hs-var">isSystemName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681079270"><span class="hs-identifier hs-var">tv2_name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isSystemName"><span class="hs-identifier hs-var">isSystemName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681079269"><span class="hs-identifier hs-var">tv1_name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1468"></span><span>
</span><span id="line-1469"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1470"></span><span>
</span><span id="line-1471"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1472"></span><span>    </span><span id="local-6989586621681079273"><span class="annot"><span class="annottext">lvl1 :: TcLevel
</span><a href="#local-6989586621681079273"><span class="hs-identifier hs-var hs-var">lvl1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#tcTyVarLevel"><span class="hs-identifier hs-var">tcTyVarLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079278"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1473"></span><span>    </span><span id="local-6989586621681079271"><span class="annot"><span class="annottext">lvl2 :: TcLevel
</span><a href="#local-6989586621681079271"><span class="hs-identifier hs-var hs-var">lvl2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#tcTyVarLevel"><span class="hs-identifier hs-var">tcTyVarLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079277"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1474"></span><span>    </span><span id="local-6989586621681079276"><span class="annot"><span class="annottext">pri1 :: Int
</span><a href="#local-6989586621681079276"><span class="hs-identifier hs-var hs-var">pri1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Int
</span><a href="GHC.Tc.Utils.Unify.html#lhsPriority"><span class="hs-identifier hs-var">lhsPriority</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079278"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1475"></span><span>    </span><span id="local-6989586621681079275"><span class="annot"><span class="annottext">pri2 :: Int
</span><a href="#local-6989586621681079275"><span class="hs-identifier hs-var hs-var">pri2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Int
</span><a href="GHC.Tc.Utils.Unify.html#lhsPriority"><span class="hs-identifier hs-var">lhsPriority</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079277"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1476"></span><span>    </span><span id="local-6989586621681079269"><span class="annot"><span class="annottext">tv1_name :: Name
</span><a href="#local-6989586621681079269"><span class="hs-identifier hs-var hs-var">tv1_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Name
</span><a href="GHC.Types.Var.html#varName"><span class="hs-identifier hs-var hs-var">Var.varName</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079278"><span class="hs-identifier hs-var">tv1</span></a></span><span>
</span><span id="line-1477"></span><span>    </span><span id="local-6989586621681079270"><span class="annot"><span class="annottext">tv2_name :: Name
</span><a href="#local-6989586621681079270"><span class="hs-identifier hs-var hs-var">tv2_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Name
</span><a href="GHC.Types.Var.html#varName"><span class="hs-identifier hs-var hs-var">Var.varName</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079277"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1478"></span><span>
</span><span id="line-1479"></span><span>
</span><span id="line-1480"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#lhsPriority"><span class="hs-identifier hs-type">lhsPriority</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-1481"></span><span class="hs-comment">-- Higher =&gt; more important to be on the LHS</span><span>
</span><span id="line-1482"></span><span class="hs-comment">-- See Note [TyVar/TyVar orientation]</span><span>
</span><span id="line-1483"></span><span id="lhsPriority"><span class="annot"><span class="annottext">lhsPriority :: TcTyVar -&gt; Int
</span><a href="GHC.Tc.Utils.Unify.html#lhsPriority"><span class="hs-identifier hs-var hs-var">lhsPriority</span></a></span></span><span> </span><span id="local-6989586621681079265"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079265"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1484"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTyVar</span><span> </span><span class="hs-identifier">tv</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tv</span><span class="hs-special">)</span><span>
</span><span id="line-1485"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079265"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1486"></span><span>      </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#RuntimeUnk"><span class="hs-identifier hs-var">RuntimeUnk</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1487"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#SkolemTv"><span class="hs-identifier hs-type">SkolemTv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1488"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_info :: TcTyVarDetails -&gt; MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#mtv_info"><span class="hs-identifier hs-var">mtv_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079258"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681079258"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681079258"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1489"></span><span>                                     </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#FlatSkolTv"><span class="hs-identifier hs-var">FlatSkolTv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-1490"></span><span>                                     </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span>
</span><span id="line-1491"></span><span>                                     </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span>
</span><span id="line-1492"></span><span>                                     </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#FlatMetaTv"><span class="hs-identifier hs-var">FlatMetaTv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span>
</span><span id="line-1493"></span><span class="hs-comment">{- Note [TyVar/TyVar orientation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Given (a ~ b), should we orient the CTyEqCan as (a~b) or (b~a)?
This is a surprisingly tricky question! This is invariant (TyEq:TV).

The question is answered by swapOverTyVars, which is use
  - in the eager unifier, in GHC.Tc.Utils.Unify.uUnfilledVar1
  - in the constraint solver, in GHC.Tc.Solver.Canonical.canEqTyVarHomo

First note: only swap if you have to!
   See Note [Avoid unnecessary swaps]

So we look for a positive reason to swap, using a three-step test:

* Level comparison. If 'a' has deeper level than 'b',
  put 'a' on the left.  See Note [Deeper level on the left]

* Priority.  If the levels are the same, look at what kind of
  type variable it is, using 'lhsPriority'.

  Generally speaking we always try to put a MetaTv on the left
  in preference to SkolemTv or RuntimeUnkTv:
     a) Because the MetaTv may be touchable and can be unified
     b) Even if it's not touchable, GHC.Tc.Solver.floatEqualities
        looks for meta tyvars on the left

  Tie-breaking rules for MetaTvs:
  - FlatMetaTv = 4: always put on the left.
        See Note [Fmv Orientation Invariant]

        NB: FlatMetaTvs always have the current level, never an
        outer one.  So nothing can be deeper than a FlatMetaTv.

  - TauTv = 3: if we have  tyv_tv ~ tau_tv,
       put tau_tv on the left because there are fewer
       restrictions on updating TauTvs.  Or to say it another
       way, then we won't lose the TyVarTv flag

  - TyVarTv = 2: remember, flat-skols are *only* updated by
       the unflattener, never unified, so TyVarTvs come next

  - FlatSkolTv = 1: put on the left in preference to a SkolemTv.
       See Note [Eliminate flat-skols]

* Names. If the level and priority comparisons are all
  equal, try to eliminate a TyVars with a System Name in
  favour of ones with a Name derived from a user type signature

* Age.  At one point in the past we tried to break any remaining
  ties by eliminating the younger type variable, based on their
  Uniques.  See Note [Eliminate younger unification variables]
  (which also explains why we don't do this any more)

Note [Unification variables on the left]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For wanteds, but not givens, swap (skolem ~ meta-tv) regardless of
level, so that the unification variable is on the left.

* We /don't/ want this for Givens because if we ave
    [G] a[2] ~ alpha[1]
    [W] Bool ~ a[2]
  we want to rewrite the wanted to Bool ~ alpha[1],
  so we can float the constraint and solve it.

* But for Wanteds putting the unification variable on
  the left means an easier job when floating, and when
  reporting errors -- just fewer cases to consider.

  In particular, we get better skolem-escape messages:
  see #18114

Note [Deeper level on the left]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The most important thing is that we want to put tyvars with
the deepest level on the left.  The reason to do so differs for
Wanteds and Givens, but either way, deepest wins!  Simple.

* Wanteds.  Putting the deepest variable on the left maximise the
  chances that it's a touchable meta-tyvar which can be solved.

* Givens. Suppose we have something like
     forall a[2]. b[1] ~ a[2] =&gt; beta[1] ~ a[2]

  If we orient the Given a[2] on the left, we'll rewrite the Wanted to
  (beta[1] ~ b[1]), and that can float out of the implication.
  Otherwise it can't.  By putting the deepest variable on the left
  we maximise our changes of eliminating skolem capture.

  See also GHC.Tc.Solver.Monad Note [Let-bound skolems] for another reason
  to orient with the deepest skolem on the left.

  IMPORTANT NOTE: this test does a level-number comparison on
  skolems, so it's important that skolems have (accurate) level
  numbers.

See #15009 for an further analysis of why &quot;deepest on the left&quot;
is a good plan.

Note [Fmv Orientation Invariant]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   * We always orient a constraint
        fmv ~ alpha
     with fmv on the left, even if alpha is
     a touchable unification variable

Reason: doing it the other way round would unify alpha:=fmv, but that
really doesn't add any info to alpha.  But a later constraint alpha ~
Int might unlock everything.  Comment:9 of #12526 gives a detailed
example.

WARNING: I've gone to and fro on this one several times.
I'm now pretty sure that unifying alpha:=fmv is a bad idea!
So orienting with fmvs on the left is a good thing.

This example comes from IndTypesPerfMerge. (Others include
T10226, T10009.)
    From the ambiguity check for
      f :: (F a ~ a) =&gt; a
    we get:
          [G] F a ~ a
          [WD] F alpha ~ alpha, alpha ~ a

    From Givens we get
          [G] F a ~ fsk, fsk ~ a

    Now if we flatten we get
          [WD] alpha ~ fmv, F alpha ~ fmv, alpha ~ a

    Now, if we unified alpha := fmv, we'd get
          [WD] F fmv ~ fmv, [WD] fmv ~ a
    And now we are stuck.

So instead the Fmv Orientation Invariant puts the fmv on the
left, giving
      [WD] fmv ~ alpha, [WD] F alpha ~ fmv, [WD] alpha ~ a

    Now we get alpha:=a, and everything works out

Note [Eliminate flat-skols]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have  [G] Num (F [a])
then we flatten to
     [G] Num fsk
     [G] F [a] ~ fsk
where fsk is a flatten-skolem (FlatSkolTv). Suppose we have
      type instance F [a] = a
then we'll reduce the second constraint to
     [G] a ~ fsk
and then replace all uses of 'a' with fsk.  That's bad because
in error messages instead of saying 'a' we'll say (F [a]).  In all
places, including those where the programmer wrote 'a' in the first
place.  Very confusing!  See #7862.

Solution: re-orient a~fsk to fsk~a, so that we preferentially eliminate
the fsk.

Note [Avoid unnecessary swaps]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we swap without actually improving matters, we can get an infinite loop.
Consider
    work item:  a ~ b
   inert item:  b ~ c
We canonicalise the work-item to (a ~ c).  If we then swap it before
adding to the inert set, we'll add (c ~ a), and therefore kick out the
inert guy, so we get
   new work item:  b ~ c
   inert item:     c ~ a
And now the cycle just repeats

Note [Eliminate younger unification variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Given a choice of unifying
     alpha := beta   or   beta := alpha
we try, if possible, to eliminate the &quot;younger&quot; one, as determined
by `ltUnique`.  Reason: the younger one is less likely to appear free in
an existing inert constraint, and hence we are less likely to be forced
into kicking out and rewriting inert constraints.

This is a performance optimisation only.  It turns out to fix
#14723 all by itself, but clearly not reliably so!

It's simple to implement (see nicer_to_update_tv2 in swapOverTyVars).
But, to my surprise, it didn't seem to make any significant difference
to the compiler's performance, so I didn't take it any further.  Still
it seemed to too nice to discard altogether, so I'm leaving these
notes.  SLPJ Jan 18.
-}</span><span>
</span><span id="line-1680"></span><span>
</span><span id="line-1681"></span><span class="hs-comment">-- @trySpontaneousSolve wi@ solves equalities where one side is a</span><span>
</span><span id="line-1682"></span><span class="hs-comment">-- touchable unification variable.</span><span>
</span><span id="line-1683"></span><span class="hs-comment">-- Returns True &lt;=&gt; spontaneous solve happened</span><span>
</span><span id="line-1684"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#canSolveByUnification"><span class="hs-identifier hs-type">canSolveByUnification</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1685"></span><span id="canSolveByUnification"><span class="annot"><span class="annottext">canSolveByUnification :: TcLevel -&gt; TcTyVar -&gt; TcType -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#canSolveByUnification"><span class="hs-identifier hs-var hs-var">canSolveByUnification</span></a></span></span><span> </span><span id="local-6989586621681079253"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079253"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span id="local-6989586621681079252"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079252"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681079251"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079251"><span class="hs-identifier hs-var">xi</span></a></span></span><span>
</span><span id="line-1686"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTouchableMetaTyVar"><span class="hs-identifier hs-var">isTouchableMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681079253"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079252"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1687"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#metaTyVarInfo"><span class="hs-identifier hs-var">metaTyVarInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079252"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1688"></span><span>      </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Bool
</span><a href="#local-6989586621681079248"><span class="hs-identifier hs-var">is_tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079251"><span class="hs-identifier hs-var">xi</span></a></span><span>
</span><span id="line-1689"></span><span>      </span><span class="annot"><span class="annottext">MetaInfo
</span><span class="hs-identifier">_</span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1690"></span><span>
</span><span id="line-1691"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-comment">-- Untouchable</span><span>
</span><span id="line-1692"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1693"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1694"></span><span>    </span><span id="local-6989586621681079248"><span class="annot"><span class="annottext">is_tyvar :: TcType -&gt; Bool
</span><a href="#local-6989586621681079248"><span class="hs-identifier hs-var hs-var">is_tyvar</span></a></span></span><span> </span><span id="local-6989586621681079247"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079247"><span class="hs-identifier hs-var">xi</span></a></span></span><span>
</span><span id="line-1695"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcTyVar
</span><a href="GHC.Tc.Utils.TcType.html#tcGetTyVar_maybe"><span class="hs-identifier hs-var">tcGetTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079247"><span class="hs-identifier hs-var">xi</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1696"></span><span>          </span><span class="annot"><span class="annottext">Maybe TcTyVar
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1697"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079246"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079246"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079246"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1698"></span><span>                       </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_info :: TcTyVarDetails -&gt; MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#mtv_info"><span class="hs-identifier hs-var">mtv_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079245"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681079245"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1699"></span><span>                                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681079245"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1700"></span><span>                                        </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1701"></span><span>                                        </span><span class="annot"><span class="annottext">MetaInfo
</span><span class="hs-identifier">_</span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1702"></span><span>                       </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#SkolemTv"><span class="hs-identifier hs-type">SkolemTv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1703"></span><span>                       </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#RuntimeUnk"><span class="hs-identifier hs-var">RuntimeUnk</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1704"></span><span>
</span><span id="line-1705"></span><span class="hs-comment">{- Note [Prevent unification with type families]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We prevent unification with type families because of an uneasy compromise.
It's perfectly sound to unify with type families, and it even improves the
error messages in the testsuite. It also modestly improves performance, at
least in some cases. But it's disastrous for test case perf/compiler/T3064.
Here is the problem: Suppose we have (F ty) where we also have [G] F ty ~ a.
What do we do? Do we reduce F? Or do we use the given? Hard to know what's
best. GHC reduces. This is a disaster for T3064, where the type's size
spirals out of control during reduction. (We're not helped by the fact that
the flattener re-flattens all the arguments every time around.) If we prevent
unification with type families, then the solver happens to use the equality
before expanding the type family.

It would be lovely in the future to revisit this problem and remove this
extra, unnecessary check. But we retain it for now as it seems to work
better in practice.

Note [Refactoring hazard: checkTauTvUpdate]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I (Richard E.) have a sad story about refactoring this code, retained here
to prevent others (or a future me!) from falling into the same traps.

It all started with #11407, which was caused by the fact that the TyVarTy
case of defer_me didn't look in the kind. But it seemed reasonable to
simply remove the defer_me check instead.

It referred to two Notes (since removed) that were out of date, and the
fast_check code in occurCheckExpand seemed to do just about the same thing as
defer_me. The one piece that defer_me did that wasn't repeated by
occurCheckExpand was the type-family check. (See Note [Prevent unification
with type families].) So I checked the result of occurCheckExpand for any
type family occurrences and deferred if there were any. This was done
in commit e9bf7bb5cc9fb3f87dd05111aa23da76b86a8967 .

This approach turned out not to be performant, because the expanded
type was bigger than the original type, and tyConsOfType (needed to
see if there are any type family occurrences) looks through type
synonyms. So it then struck me that we could dispense with the
defer_me check entirely. This simplified the code nicely, and it cut
the allocations in T5030 by half. But, as documented in Note [Prevent
unification with type families], this destroyed performance in
T3064. Regardless, I missed this regression and the change was
committed as 3f5d1a13f112f34d992f6b74656d64d95a3f506d .

Bottom lines:
 * defer_me is back, but now fixed w.r.t. #11407.
 * Tread carefully before you start to refactor here. There can be
   lots of hard-to-predict consequences.

Note [Type synonyms and the occur check]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Generally speaking we try to update a variable with type synonyms not
expanded, which improves later error messages, unless looking
inside a type synonym may help resolve a spurious occurs check
error. Consider:
          type A a = ()

          f :: (A a -&gt; a -&gt; ()) -&gt; ()
          f = \ _ -&gt; ()

          x :: ()
          x = f (\ x p -&gt; p x)

We will eventually get a constraint of the form t ~ A t. The ok function above will
properly expand the type (A t) to just (), which is ok to be unified with t. If we had
unified with the original type A t, we would lead the type checker into an infinite loop.

Hence, if the occurs check fails for a type synonym application, then (and *only* then),
the ok function expands the synonym to detect opportunities for occurs check success using
the underlying definition of the type synonym.

The same applies later on in the constraint interaction code; see GHC.Tc.Solver.Interact,
function @occ_check_ok@.

Note [Non-TcTyVars in GHC.Tc.Utils.Unify]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Because the same code is now shared between unifying types and unifying
kinds, we sometimes will see proper TyVars floating around the unifier.
Example (from test case polykinds/PolyKinds12):

    type family Apply (f :: k1 -&gt; k2) (x :: k1) :: k2
    type instance Apply g y = g y

When checking the instance declaration, we first *kind-check* the LHS
and RHS, discovering that the instance really should be

    type instance Apply k3 k4 (g :: k3 -&gt; k4) (y :: k3) = g y

During this kind-checking, all the tyvars will be TcTyVars. Then, however,
as a second pass, we desugar the RHS (which is done in functions prefixed
with &quot;tc&quot; in GHC.Tc.TyCl&quot;). By this time, all the kind-vars are proper
TyVars, not TcTyVars, get some kind unification must happen.

Thus, we always check if a TyVar is a TcTyVar before asking if it's a
meta-tyvar.

This used to not be necessary for type-checking (that is, before * :: *)
because expressions get desugared via an algorithm separate from
type-checking (with wrappers, etc.). Types get desugared very differently,
causing this wibble in behavior seen here.
-}</span><span>
</span><span id="line-1807"></span><span>
</span><span id="line-1808"></span><span class="hs-keyword">data</span><span> </span><span id="LookupTyVarResult"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#LookupTyVarResult"><span class="hs-identifier hs-var">LookupTyVarResult</span></a></span></span><span>  </span><span class="hs-comment">-- The result of a lookupTcTyVar call</span><span>
</span><span id="line-1809"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="Unfilled"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#Unfilled"><span class="hs-identifier hs-var">Unfilled</span></a></span></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyVarDetails"><span class="hs-identifier hs-type">TcTyVarDetails</span></a></span><span>     </span><span class="hs-comment">-- SkolemTv or virgin MetaTv</span><span>
</span><span id="line-1810"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="Filled"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#Filled"><span class="hs-identifier hs-var">Filled</span></a></span></span><span>   </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-1811"></span><span>
</span><span id="line-1812"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#lookupTcTyVar"><span class="hs-identifier hs-type">lookupTcTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#LookupTyVarResult"><span class="hs-identifier hs-type">LookupTyVarResult</span></a></span><span>
</span><span id="line-1813"></span><span id="lookupTcTyVar"><span class="annot"><span class="annottext">lookupTcTyVar :: TcTyVar -&gt; TcM LookupTyVarResult
</span><a href="GHC.Tc.Utils.Unify.html#lookupTcTyVar"><span class="hs-identifier hs-var hs-var">lookupTcTyVar</span></a></span></span><span> </span><span id="local-6989586621681079244"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079244"><span class="hs-identifier hs-var">tyvar</span></a></span></span><span>
</span><span id="line-1814"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: TcTyVarDetails -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079242"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681079242"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681079241"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-1815"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079240"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079240"><span class="hs-identifier hs-var">meta_details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcM MetaDetails
forall a env. IORef a -&gt; IOEnv env a
</span><a href="GHC.Data.IOEnv.html#readMutVar"><span class="hs-identifier hs-var">readMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681079242"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-1816"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079240"><span class="hs-identifier hs-var">meta_details</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1817"></span><span>           </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681079238"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079238"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LookupTyVarResult -&gt; TcM LookupTyVarResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; LookupTyVarResult
</span><a href="GHC.Tc.Utils.Unify.html#Filled"><span class="hs-identifier hs-var">Filled</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079238"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1818"></span><span>           </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079237"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079237"><span class="hs-identifier hs-var">is_touchable</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.Monad.html#isTouchableTcM"><span class="hs-identifier hs-var">isTouchableTcM</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079244"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-1819"></span><span>                             </span><span class="hs-comment">-- Note [Unifying untouchables]</span><span>
</span><span id="line-1820"></span><span>                       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079237"><span class="hs-identifier hs-var">is_touchable</span></a></span><span> </span><span class="hs-keyword">then</span><span>
</span><span id="line-1821"></span><span>                            </span><span class="annot"><span class="annottext">LookupTyVarResult -&gt; TcM LookupTyVarResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarDetails -&gt; LookupTyVarResult
</span><a href="GHC.Tc.Utils.Unify.html#Unfilled"><span class="hs-identifier hs-var">Unfilled</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681079241"><span class="hs-identifier hs-var">details</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1822"></span><span>                         </span><span class="hs-keyword">else</span><span>
</span><span id="line-1823"></span><span>                            </span><span class="annot"><span class="annottext">LookupTyVarResult -&gt; TcM LookupTyVarResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarDetails -&gt; LookupTyVarResult
</span><a href="GHC.Tc.Utils.Unify.html#Unfilled"><span class="hs-identifier hs-var">Unfilled</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#vanillaSkolemTv"><span class="hs-identifier hs-var">vanillaSkolemTv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1824"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1825"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LookupTyVarResult -&gt; TcM LookupTyVarResult
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarDetails -&gt; LookupTyVarResult
</span><a href="GHC.Tc.Utils.Unify.html#Unfilled"><span class="hs-identifier hs-var">Unfilled</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681079241"><span class="hs-identifier hs-var">details</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1826"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1827"></span><span>    </span><span id="local-6989586621681079241"><span class="annot"><span class="annottext">details :: TcTyVarDetails
</span><a href="#local-6989586621681079241"><span class="hs-identifier hs-var hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079244"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-1828"></span><span>
</span><span id="line-1829"></span><span class="hs-comment">{-
Note [Unifying untouchables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We treat an untouchable type variable as if it was a skolem.  That
ensures it won't unify with anything.  It's a slight hack, because
we return a made-up TcTyVarDetails, but I think it works smoothly.
-}</span><span>
</span><span id="line-1836"></span><span>
</span><span id="line-1837"></span><span class="hs-comment">-- | Breaks apart a function kind into its pieces.</span><span>
</span><span id="line-1838"></span><span id="local-6989586621681080357"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#matchExpectedFunKind"><span class="hs-identifier hs-type">matchExpectedFunKind</span></a></span><span>
</span><span id="line-1839"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080357"><span class="hs-identifier hs-type">fun</span></a></span><span>
</span><span id="line-1840"></span><span>  </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681080357"><span class="hs-identifier hs-type">fun</span></a></span><span>             </span><span class="hs-comment">-- ^ type, only for errors</span><span>
</span><span id="line-1841"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>           </span><span class="hs-comment">-- ^ n: number of desired arrows</span><span>
</span><span id="line-1842"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span>          </span><span class="hs-comment">-- ^ fun_ kind</span><span>
</span><span id="line-1843"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span></span><span>    </span><span class="hs-comment">-- ^ co :: fun_kind ~ (arg1 -&gt; ... -&gt; argn -&gt; res)</span><span>
</span><span id="line-1844"></span><span>
</span><span id="line-1845"></span><span id="matchExpectedFunKind"><span class="annot"><span class="annottext">matchExpectedFunKind :: forall fun. Outputable fun =&gt; fun -&gt; Int -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#matchExpectedFunKind"><span class="hs-identifier hs-var hs-var">matchExpectedFunKind</span></a></span></span><span> </span><span id="local-6989586621681079233"><span class="annot"><span class="annottext">fun
</span><a href="#local-6989586621681079233"><span class="hs-identifier hs-var">hs_ty</span></a></span></span><span> </span><span id="local-6989586621681079232"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079232"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079231"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079231"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079232"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079231"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-1846"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1847"></span><span>    </span><span id="local-6989586621681079230"><span class="annot"><span class="annottext">go :: Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079230"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621681079221"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079221"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkNomReflCo"><span class="hs-identifier hs-var">mkNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079221"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1848"></span><span>
</span><span id="line-1849"></span><span>    </span><span class="annot"><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079220"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079220"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079219"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079219"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079218"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079218"><span class="hs-identifier hs-var">k'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079219"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079220"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079218"><span class="hs-identifier hs-var">k'</span></a></span><span>
</span><span id="line-1850"></span><span>
</span><span id="line-1851"></span><span>    </span><span class="annot"><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079217"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079217"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079216"><span class="annot"><span class="annottext">k :: TcType
</span><a href="#local-6989586621681079216"><span class="hs-identifier hs-var">k</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079215"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079215"><span class="hs-identifier hs-var">kvar</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1852"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079215"><span class="hs-identifier hs-var">kvar</span></a></span><span>
</span><span id="line-1853"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079214"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079214"><span class="hs-identifier hs-var">maybe_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcM MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var">readMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079215"><span class="hs-identifier hs-var">kvar</span></a></span><span>
</span><span id="line-1854"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681079214"><span class="hs-identifier hs-var">maybe_kind</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1855"></span><span>                </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681079213"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079213"><span class="hs-identifier hs-var">fun_kind</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079217"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079213"><span class="hs-identifier hs-var">fun_kind</span></a></span><span>
</span><span id="line-1856"></span><span>                </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>             </span><span class="annot"><span class="annottext">Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079212"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079217"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079216"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1857"></span><span>
</span><span id="line-1858"></span><span>    </span><span class="annot"><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079211"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079211"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681079210"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079210"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621681079209"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079209"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span id="local-6989586621681079208"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079208"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1859"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079207"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079207"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079211"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079208"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-1860"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Coercion -&gt; Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcFunCo"><span class="hs-identifier hs-var">mkTcFunCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcNomReflCo"><span class="hs-identifier hs-var">mkTcNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079210"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcType -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcNomReflCo"><span class="hs-identifier hs-var">mkTcNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079209"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079207"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1861"></span><span>
</span><span id="line-1862"></span><span>    </span><span class="annot"><a href="#local-6989586621681079230"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681079205"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079205"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079204"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079204"><span class="hs-identifier hs-var">other</span></a></span></span><span>
</span><span id="line-1863"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079212"><span class="hs-identifier hs-var">defer</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079205"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079204"><span class="hs-identifier hs-var">other</span></a></span><span>
</span><span id="line-1864"></span><span>
</span><span id="line-1865"></span><span>    </span><span id="local-6989586621681079212"><span class="annot"><span class="annottext">defer :: Int -&gt; TcType -&gt; TcM Coercion
</span><a href="#local-6989586621681079212"><span class="hs-identifier hs-var hs-var">defer</span></a></span></span><span> </span><span id="local-6989586621681079201"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079201"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681079200"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079200"><span class="hs-identifier hs-var">k</span></a></span></span><span>
</span><span id="line-1866"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681079199"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079199"><span class="hs-identifier hs-var">arg_kinds</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcM ThetaType
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVars"><span class="hs-identifier hs-var">newMetaKindVars</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681079201"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-1867"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681079197"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079197"><span class="hs-identifier hs-var">res_kind</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcType
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVar"><span class="hs-identifier hs-var">newMetaKindVar</span></a></span><span>
</span><span id="line-1868"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681079195"><span class="annot"><span class="annottext">new_fun :: TcType
</span><a href="#local-6989586621681079195"><span class="hs-identifier hs-var hs-var">new_fun</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTysMany"><span class="hs-identifier hs-var">mkVisFunTysMany</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079199"><span class="hs-identifier hs-var">arg_kinds</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079197"><span class="hs-identifier hs-var">res_kind</span></a></span><span>
</span><span id="line-1869"></span><span>                 </span><span id="local-6989586621681079192"><span class="annot"><span class="annottext">origin :: CtOrigin
</span><a href="#local-6989586621681079192"><span class="hs-identifier hs-var hs-var">origin</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEqOrigin :: TcType -&gt; TcType -&gt; Maybe SDoc -&gt; Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079200"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-1870"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: TcType
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079195"><span class="hs-identifier hs-var">new_fun</span></a></span><span>
</span><span id="line-1871"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_thing :: Maybe SDoc
</span><a href="GHC.Tc.Types.Origin.html#uo_thing"><span class="hs-identifier hs-var">uo_thing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Maybe SDoc
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">fun -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">fun
</span><a href="#local-6989586621681079233"><span class="hs-identifier hs-var">hs_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1872"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_visible :: Bool
</span><a href="GHC.Tc.Types.Origin.html#uo_visible"><span class="hs-identifier hs-var">uo_visible</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1873"></span><span>                                        </span><span class="hs-special">}</span><span>
</span><span id="line-1874"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TypeOrKind -&gt; CtOrigin -&gt; TcType -&gt; TcType -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#uType"><span class="hs-identifier hs-var">uType</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#KindLevel"><span class="hs-identifier hs-var">KindLevel</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681079192"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079200"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079195"><span class="hs-identifier hs-var">new_fun</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1875"></span><span>
</span><span id="line-1876"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                 Occurrence checking
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-1881"></span><span>
</span><span id="line-1882"></span><span>
</span><span id="line-1883"></span><span class="hs-comment">{-  Note [Occurrence checking: look inside kinds]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we are considering unifying
   (alpha :: *)  ~  Int -&gt; (beta :: alpha -&gt; alpha)
This may be an error (what is that alpha doing inside beta's kind?),
but we must not make the mistake of actually unifying or we'll
build an infinite data structure.  So when looking for occurrences
of alpha in the rhs, we must look in the kinds of type variables
that occur there.

NB: we may be able to remove the problem via expansion; see
    Note [Occurs check expansion].  So we have to try that.

Note [Checking for foralls]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unless we have -XImpredicativeTypes (which is a totally unsupported
feature), we do not want to unify
    alpha ~ (forall a. a-&gt;a) -&gt; Int
So we look for foralls hidden inside the type, and it's convenient
to do that at the same time as the occurs check (which looks for
occurrences of alpha).

However, it's not just a question of looking for foralls /anywhere/!
Consider
   (alpha :: forall k. k-&gt;*)  ~  (beta :: forall k. k-&gt;*)
This is legal; e.g. dependent/should_compile/T11635.

We don't want to reject it because of the forall in beta's kind,
but (see Note [Occurrence checking: look inside kinds]) we do
need to look in beta's kind.  So we carry a flag saying if a 'forall'
is OK, and switch the flag on when stepping inside a kind.

Why is it OK?  Why does it not count as impredicative polymorphism?
The reason foralls are bad is because we reply on &quot;seeing&quot; foralls
when doing implicit instantiation.  But the forall inside the kind is
fine.  We'll generate a kind equality constraint
  (forall k. k-&gt;*) ~ (forall k. k-&gt;*)
to check that the kinds of lhs and rhs are compatible.  If alpha's
kind had instead been
  (alpha :: kappa)
then this kind equality would rightly complain about unifying kappa
with (forall k. k-&gt;*)

-}</span><span>
</span><span id="line-1927"></span><span>
</span><span id="line-1928"></span><span class="hs-keyword">data</span><span> </span><span id="MetaTyVarUpdateResult"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-var">MetaTyVarUpdateResult</span></a></span></span><span> </span><span id="local-6989586621681080330"><span class="annot"><a href="#local-6989586621681080330"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1929"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="MTVU_OK"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-var">MTVU_OK</span></a></span></span><span> </span><span class="annot"><a href="#local-6989586621681080330"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-1930"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="MTVU_Bad"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span></span><span>          </span><span class="hs-comment">-- Forall, predicate, or type family</span><span>
</span><span id="line-1931"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="MTVU_HoleBlocker"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span></span><span>  </span><span class="hs-comment">-- Blocking coercion hole</span><span>
</span><span id="line-1932"></span><span>        </span><span class="hs-comment">-- See Note [Equalities with incompatible kinds] in &quot;GHC.Tc.Solver.Canonical&quot;</span><span>
</span><span id="line-1933"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="MTVU_Occurs"><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span></span><span>
</span><span id="line-1934"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681079185"><span id="local-6989586621681079187"><span class="annot"><span class="annottext">(forall a b.
 (a -&gt; b) -&gt; MetaTyVarUpdateResult a -&gt; MetaTyVarUpdateResult b)
-&gt; (forall a b.
    a -&gt; MetaTyVarUpdateResult b -&gt; MetaTyVarUpdateResult a)
-&gt; Functor MetaTyVarUpdateResult
forall a b. a -&gt; MetaTyVarUpdateResult b -&gt; MetaTyVarUpdateResult a
forall a b.
(a -&gt; b) -&gt; MetaTyVarUpdateResult a -&gt; MetaTyVarUpdateResult b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; MetaTyVarUpdateResult b -&gt; MetaTyVarUpdateResult a
$c&lt;$ :: forall a b. a -&gt; MetaTyVarUpdateResult b -&gt; MetaTyVarUpdateResult a
fmap :: forall a b.
(a -&gt; b) -&gt; MetaTyVarUpdateResult a -&gt; MetaTyVarUpdateResult b
$cfmap :: forall a b.
(a -&gt; b) -&gt; MetaTyVarUpdateResult a -&gt; MetaTyVarUpdateResult b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-1935"></span><span>
</span><span id="line-1936"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681079173"><span id="local-6989586621681079175"><span id="local-6989586621681079177"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1937"></span><span>      </span><span id="local-6989586621681079171"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; MetaTyVarUpdateResult a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; MetaTyVarUpdateResult a
forall a. a -&gt; MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-var">MTVU_OK</span></a></span><span>
</span><span id="line-1938"></span><span>      </span><span id="local-6989586621681079169"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b.
MetaTyVarUpdateResult (a -&gt; b)
-&gt; MetaTyVarUpdateResult a -&gt; MetaTyVarUpdateResult b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult (a -&gt; b)
-&gt; MetaTyVarUpdateResult a -&gt; MetaTyVarUpdateResult b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-1939"></span><span>
</span><span id="line-1940"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681079161"><span id="local-6989586621681079163"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1941"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-type">MTVU_OK</span></a></span><span> </span><span id="local-6989586621681079159"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681079159"><span class="hs-identifier hs-var">x</span></a></span></span><span>        </span><span id="local-6989586621681079158"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b.
MetaTyVarUpdateResult a
-&gt; (a -&gt; MetaTyVarUpdateResult b) -&gt; MetaTyVarUpdateResult b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621681079157"><span class="annot"><span class="annottext">a -&gt; MetaTyVarUpdateResult b
</span><a href="#local-6989586621681079157"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; MetaTyVarUpdateResult b
</span><a href="#local-6989586621681079157"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681079159"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-1942"></span><span>  </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>         </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; MetaTyVarUpdateResult b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult b
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>
</span><span id="line-1943"></span><span>  </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; MetaTyVarUpdateResult b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult b
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span>
</span><span id="line-1944"></span><span>  </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; MetaTyVarUpdateResult b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult b
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>
</span><span id="line-1945"></span><span>
</span><span id="line-1946"></span><span id="local-6989586621681080329"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681079154"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080329"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681080329"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1947"></span><span>  </span><span id="local-6989586621681079151"><span class="annot"><span class="annottext">ppr :: MetaTyVarUpdateResult a -&gt; SDoc
</span><a href="#local-6989586621681079151"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-type">MTVU_OK</span></a></span><span> </span><span id="local-6989586621681079150"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681079150"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MTVU_OK&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681079150"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-1948"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MTVU_Bad&quot;</span></span><span>
</span><span id="line-1949"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MTVU_HoleBlocker&quot;</span></span><span>
</span><span id="line-1950"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;MTVU_Occurs&quot;</span></span></span><span>
</span><span id="line-1951"></span><span>
</span><span id="line-1952"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#occCheckForErrors"><span class="hs-identifier hs-type">occCheckForErrors</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1953"></span><span class="hs-comment">-- Just for error-message generation; so we return MetaTyVarUpdateResult</span><span>
</span><span id="line-1954"></span><span class="hs-comment">-- so the caller can report the right kind of error</span><span>
</span><span id="line-1955"></span><span class="hs-comment">-- Check whether</span><span>
</span><span id="line-1956"></span><span class="hs-comment">--   a) the given variable occurs in the given type.</span><span>
</span><span id="line-1957"></span><span class="hs-comment">--   b) there is a forall in the type (unless we have -XImpredicativeTypes)</span><span>
</span><span id="line-1958"></span><span id="occCheckForErrors"><span class="annot"><span class="annottext">occCheckForErrors :: DynFlags -&gt; TcTyVar -&gt; TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#occCheckForErrors"><span class="hs-identifier hs-var hs-var">occCheckForErrors</span></a></span></span><span> </span><span id="local-6989586621681079148"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079148"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681079147"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079147"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681079146"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079146"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-1959"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool -&gt; TcTyVar -&gt; TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#preCheck"><span class="hs-identifier hs-var">preCheck</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079148"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079147"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079146"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1960"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-type">MTVU_OK</span></a></span><span> </span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; MetaTyVarUpdateResult ()
forall a. a -&gt; MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-var">MTVU_OK</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1961"></span><span>      </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>
</span><span id="line-1962"></span><span>      </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span>
</span><span id="line-1963"></span><span>      </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#occCheckExpand"><span class="hs-identifier hs-var">occCheckExpand</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079147"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079146"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1964"></span><span>                            </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>
</span><span id="line-1965"></span><span>                            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; MetaTyVarUpdateResult ()
forall a. a -&gt; MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-var">MTVU_OK</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1966"></span><span>
</span><span id="line-1967"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-1968"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#metaTyVarUpdateOK"><span class="hs-identifier hs-type">metaTyVarUpdateOK</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-1969"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>             </span><span class="hs-comment">-- tv :: k1</span><span>
</span><span id="line-1970"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>              </span><span class="hs-comment">-- ty :: k2</span><span>
</span><span id="line-1971"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>        </span><span class="hs-comment">-- possibly-expanded ty</span><span>
</span><span id="line-1972"></span><span class="hs-comment">-- (metaTyVarUpdateOK tv ty)</span><span>
</span><span id="line-1973"></span><span class="hs-comment">-- We are about to update the meta-tyvar tv with ty</span><span>
</span><span id="line-1974"></span><span class="hs-comment">-- Check (a) that tv doesn't occur in ty (occurs check)</span><span>
</span><span id="line-1975"></span><span class="hs-comment">--       (b) that ty does not have any foralls</span><span>
</span><span id="line-1976"></span><span class="hs-comment">--           (in the impredicative case), or type functions</span><span>
</span><span id="line-1977"></span><span class="hs-comment">--       (c) that ty does not have any blocking coercion holes</span><span>
</span><span id="line-1978"></span><span class="hs-comment">--           See Note [Equalities with incompatible kinds] in &quot;GHC.Tc.Solver.Canonical&quot;</span><span>
</span><span id="line-1979"></span><span class="hs-comment">--</span><span>
</span><span id="line-1980"></span><span class="hs-comment">-- We have two possible outcomes:</span><span>
</span><span id="line-1981"></span><span class="hs-comment">-- (1) Return the type to update the type variable with,</span><span>
</span><span id="line-1982"></span><span class="hs-comment">--        [we know the update is ok]</span><span>
</span><span id="line-1983"></span><span class="hs-comment">-- (2) Return Nothing,</span><span>
</span><span id="line-1984"></span><span class="hs-comment">--        [the update might be dodgy]</span><span>
</span><span id="line-1985"></span><span class="hs-comment">--</span><span>
</span><span id="line-1986"></span><span class="hs-comment">-- Note that &quot;Nothing&quot; does not mean &quot;definite error&quot;.  For example</span><span>
</span><span id="line-1987"></span><span class="hs-comment">--   type family F a</span><span>
</span><span id="line-1988"></span><span class="hs-comment">--   type instance F Int = Int</span><span>
</span><span id="line-1989"></span><span class="hs-comment">-- consider</span><span>
</span><span id="line-1990"></span><span class="hs-comment">--   a ~ F a</span><span>
</span><span id="line-1991"></span><span class="hs-comment">-- This is perfectly reasonable, if we later get a ~ Int.  For now, though,</span><span>
</span><span id="line-1992"></span><span class="hs-comment">-- we return Nothing, leaving it to the later constraint simplifier to</span><span>
</span><span id="line-1993"></span><span class="hs-comment">-- sort matters out.</span><span>
</span><span id="line-1994"></span><span class="hs-comment">--</span><span>
</span><span id="line-1995"></span><span class="hs-comment">-- See Note [Refactoring hazard: checkTauTvUpdate]</span><span>
</span><span id="line-1996"></span><span>
</span><span id="line-1997"></span><span id="metaTyVarUpdateOK"><span class="annot"><span class="annottext">metaTyVarUpdateOK :: DynFlags -&gt; TcTyVar -&gt; TcType -&gt; MetaTyVarUpdateResult TcType
</span><a href="GHC.Tc.Utils.Unify.html#metaTyVarUpdateOK"><span class="hs-identifier hs-var hs-var">metaTyVarUpdateOK</span></a></span></span><span> </span><span id="local-6989586621681079143"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079143"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681079142"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079142"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681079141"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079141"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-1998"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool -&gt; TcTyVar -&gt; TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#preCheck"><span class="hs-identifier hs-var">preCheck</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079143"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079142"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079141"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1999"></span><span>         </span><span class="hs-comment">-- False &lt;=&gt; type families not ok</span><span>
</span><span id="line-2000"></span><span>         </span><span class="hs-comment">-- See Note [Prevent unification with type families]</span><span>
</span><span id="line-2001"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-type">MTVU_OK</span></a></span><span> </span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult TcType
forall a. a -&gt; MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-var">MTVU_OK</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079141"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2002"></span><span>      </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult TcType
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>          </span><span class="hs-comment">-- forall, predicate, type function</span><span>
</span><span id="line-2003"></span><span>      </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult TcType
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span>  </span><span class="hs-comment">-- coercion hole</span><span>
</span><span id="line-2004"></span><span>      </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[TcTyVar] -&gt; TcType -&gt; Maybe TcType
</span><a href="GHC.Core.Type.html#occCheckExpand"><span class="hs-identifier hs-var">occCheckExpand</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079142"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079141"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2005"></span><span>                            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681079140"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079140"><span class="hs-identifier hs-var">expanded_ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult TcType
forall a. a -&gt; MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-var">MTVU_OK</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079140"><span class="hs-identifier hs-var">expanded_ty</span></a></span><span>
</span><span id="line-2006"></span><span>                            </span><span class="annot"><span class="annottext">Maybe TcType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult TcType
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>
</span><span id="line-2007"></span><span>
</span><span id="line-2008"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#preCheck"><span class="hs-identifier hs-type">preCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2009"></span><span class="hs-comment">-- A quick check for</span><span>
</span><span id="line-2010"></span><span class="hs-comment">--   (a) a forall type (unless -XImpredicativeTypes)</span><span>
</span><span id="line-2011"></span><span class="hs-comment">--   (b) a predicate type (unless -XImpredicativeTypes)</span><span>
</span><span id="line-2012"></span><span class="hs-comment">--   (c) a type family</span><span>
</span><span id="line-2013"></span><span class="hs-comment">--   (d) a blocking coercion hole</span><span>
</span><span id="line-2014"></span><span class="hs-comment">--   (e) an occurrence of the type variable (occurs check)</span><span>
</span><span id="line-2015"></span><span class="hs-comment">--</span><span>
</span><span id="line-2016"></span><span class="hs-comment">-- For (a), (b), and (c) we check only the top level of the type, NOT</span><span>
</span><span id="line-2017"></span><span class="hs-comment">-- inside the kinds of variables it mentions.  For (d) we look deeply</span><span>
</span><span id="line-2018"></span><span class="hs-comment">-- in coercions, and for (e) we do look in the kinds of course.</span><span>
</span><span id="line-2019"></span><span>
</span><span id="line-2020"></span><span id="preCheck"><span class="annot"><span class="annottext">preCheck :: DynFlags -&gt; Bool -&gt; TcTyVar -&gt; TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="GHC.Tc.Utils.Unify.html#preCheck"><span class="hs-identifier hs-var hs-var">preCheck</span></a></span></span><span> </span><span id="local-6989586621681079139"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079139"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681079138"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079138"><span class="hs-identifier hs-var">ty_fam_ok</span></a></span></span><span> </span><span id="local-6989586621681079137"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079137"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681079136"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079136"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-2021"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079136"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2022"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2023"></span><span>    </span><span id="local-6989586621681079134"><span class="annot"><span class="annottext">details :: TcTyVarDetails
</span><a href="#local-6989586621681079134"><span class="hs-identifier hs-var hs-var">details</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079137"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2024"></span><span>    </span><span id="local-6989586621681079133"><span class="annot"><span class="annottext">impredicative_ok :: Bool
</span><a href="#local-6989586621681079133"><span class="hs-identifier hs-var hs-var">impredicative_ok</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; TcTyVarDetails -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#canUnifyWithPolyType"><span class="hs-identifier hs-var">canUnifyWithPolyType</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079139"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681079134"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-2025"></span><span>
</span><span id="line-2026"></span><span>    </span><span class="annot"><a href="#local-6989586621681079131"><span class="hs-identifier hs-type">ok</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2027"></span><span>    </span><span id="local-6989586621681079131"><span class="annot"><span class="annottext">ok :: MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079131"><span class="hs-identifier hs-var hs-var">ok</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; MetaTyVarUpdateResult ()
forall a. a -&gt; MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_OK"><span class="hs-identifier hs-var">MTVU_OK</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2028"></span><span>
</span><span id="line-2029"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-type">fast_check</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#MetaTyVarUpdateResult"><span class="hs-identifier hs-type">MetaTyVarUpdateResult</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2030"></span><span>    </span><span id="local-6989586621681079135"><span class="annot"><span class="annottext">fast_check :: TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var hs-var">fast_check</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681079130"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079130"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2031"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079137"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079130"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>
</span><span id="line-2032"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079129"><span class="hs-identifier hs-var">fast_check_occ</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079130"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2033"></span><span>           </span><span class="hs-comment">-- See Note [Occurrence checking: look inside kinds]</span><span>
</span><span id="line-2034"></span><span>
</span><span id="line-2035"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span id="local-6989586621681079128"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079128"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681079127"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079127"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2036"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="#local-6989586621681079126"><span class="hs-identifier hs-var">bad_tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079128"><span class="hs-identifier hs-var">tc</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>
</span><span id="line-2037"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcType -&gt; MetaTyVarUpdateResult ())
-&gt; ThetaType -&gt; MetaTyVarUpdateResult [()]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681079127"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult [()]
-&gt; MetaTyVarUpdateResult () -&gt; MetaTyVarUpdateResult ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079131"><span class="hs-identifier hs-var">ok</span></a></span><span>
</span><span id="line-2038"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079131"><span class="hs-identifier hs-var">ok</span></a></span><span>
</span><span id="line-2039"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">ft_af :: TcType -&gt; AnonArgFlag
</span><a href="GHC.Core.TyCo.Rep.html#ft_af"><span class="hs-identifier hs-var">ft_af</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079125"><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681079125"><span class="hs-identifier hs-var">af</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_mult :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079124"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079124"><span class="hs-identifier hs-var">w</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_arg :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079123"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079123"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_res :: TcType -&gt; TcType
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681079122"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079122"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2040"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="GHC.Types.Var.html#InvisArg"><span class="hs-identifier hs-var">InvisArg</span></a></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681079125"><span class="hs-identifier hs-var">af</span></a></span><span>
</span><span id="line-2041"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079133"><span class="hs-identifier hs-var">impredicative_ok</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>
</span><span id="line-2042"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079124"><span class="hs-identifier hs-var">w</span></a></span><span>   </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
-&gt; MetaTyVarUpdateResult () -&gt; MetaTyVarUpdateResult ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079123"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
-&gt; MetaTyVarUpdateResult () -&gt; MetaTyVarUpdateResult ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079122"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-2043"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681079120"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079120"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621681079119"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079119"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079120"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
-&gt; MetaTyVarUpdateResult () -&gt; MetaTyVarUpdateResult ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079119"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-2044"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681079118"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079118"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681079117"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079117"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079118"><span class="hs-identifier hs-var">ty</span></a></span><span>  </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
-&gt; MetaTyVarUpdateResult () -&gt; MetaTyVarUpdateResult ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079116"><span class="hs-identifier hs-var">fast_check_co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079117"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-2045"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621681079115"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079115"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079116"><span class="hs-identifier hs-var">fast_check_co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079115"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-2046"></span><span>    </span><span class="annot"><a href="#local-6989586621681079135"><span class="hs-identifier hs-var">fast_check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681079112"><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079112"><span class="hs-identifier hs-var">tv'</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681079111"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079111"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2047"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079133"><span class="hs-identifier hs-var">impredicative_ok</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Bad"><span class="hs-identifier hs-var">MTVU_Bad</span></a></span><span>
</span><span id="line-2048"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079137"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; TcTyVar -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079112"><span class="hs-identifier hs-var">tv'</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079131"><span class="hs-identifier hs-var">ok</span></a></span><span>
</span><span id="line-2049"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079129"><span class="hs-identifier hs-var">fast_check_occ</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVar -&gt; TcType
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079112"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2050"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079129"><span class="hs-identifier hs-var">fast_check_occ</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079111"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2051"></span><span>       </span><span class="hs-comment">-- Under a forall we look only for occurrences of</span><span>
</span><span id="line-2052"></span><span>       </span><span class="hs-comment">-- the type variable</span><span>
</span><span id="line-2053"></span><span>
</span><span id="line-2054"></span><span>     </span><span class="hs-comment">-- For kinds, we only do an occurs check; we do not worry</span><span>
</span><span id="line-2055"></span><span>     </span><span class="hs-comment">-- about type families or foralls</span><span>
</span><span id="line-2056"></span><span>     </span><span class="hs-comment">-- See Note [Checking for foralls]</span><span>
</span><span id="line-2057"></span><span>    </span><span id="local-6989586621681079129"><span class="annot"><span class="annottext">fast_check_occ :: TcType -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079129"><span class="hs-identifier hs-var hs-var">fast_check_occ</span></a></span></span><span> </span><span id="local-6989586621681079110"><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079110"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079137"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TcType -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">TcType
</span><a href="#local-6989586621681079110"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>
</span><span id="line-2058"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079131"><span class="hs-identifier hs-var">ok</span></a></span><span>
</span><span id="line-2059"></span><span>
</span><span id="line-2060"></span><span>     </span><span class="hs-comment">-- no bother about impredicativity in coercions, as they're</span><span>
</span><span id="line-2061"></span><span>     </span><span class="hs-comment">-- inferred</span><span>
</span><span id="line-2062"></span><span>    </span><span id="local-6989586621681079116"><span class="annot"><span class="annottext">fast_check_co :: Coercion -&gt; MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079116"><span class="hs-identifier hs-var hs-var">fast_check_co</span></a></span></span><span> </span><span id="local-6989586621681079107"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079107"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_DeferTypeErrors"><span class="hs-identifier hs-var">Opt_DeferTypeErrors</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079139"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2063"></span><span>                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Core.Coercion.html#badCoercionHoleCo"><span class="hs-identifier hs-var">badCoercionHoleCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079107"><span class="hs-identifier hs-var">co</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_HoleBlocker"><span class="hs-identifier hs-var">MTVU_HoleBlocker</span></a></span><span>
</span><span id="line-2064"></span><span>        </span><span class="hs-comment">-- Wrinkle (4b) in &quot;GHC.Tc.Solver.Canonical&quot; Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-2065"></span><span>
</span><span id="line-2066"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TcTyVar
</span><a href="#local-6989586621681079137"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfCo"><span class="hs-identifier hs-var">tyCoVarsOfCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681079107"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
forall a. MetaTyVarUpdateResult a
</span><a href="GHC.Tc.Utils.Unify.html#MTVU_Occurs"><span class="hs-identifier hs-var">MTVU_Occurs</span></a></span><span>
</span><span id="line-2067"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaTyVarUpdateResult ()
</span><a href="#local-6989586621681079131"><span class="hs-identifier hs-var">ok</span></a></span><span>
</span><span id="line-2068"></span><span>
</span><span id="line-2069"></span><span>    </span><span class="annot"><a href="#local-6989586621681079126"><span class="hs-identifier hs-type">bad_tc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2070"></span><span>    </span><span id="local-6989586621681079126"><span class="annot"><span class="annottext">bad_tc :: TyCon -&gt; Bool
</span><a href="#local-6989586621681079126"><span class="hs-identifier hs-var hs-var">bad_tc</span></a></span></span><span> </span><span id="local-6989586621681079104"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079104"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-2071"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079133"><span class="hs-identifier hs-var">impredicative_ok</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTauTyCon"><span class="hs-identifier hs-var">isTauTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079104"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2072"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681079138"><span class="hs-identifier hs-var">ty_fam_ok</span></a></span><span>        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isFamFreeTyCon"><span class="hs-identifier hs-var">isFamFreeTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681079104"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2073"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2074"></span><span>
</span><span id="line-2075"></span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#canUnifyWithPolyType"><span class="hs-identifier hs-type">canUnifyWithPolyType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyVarDetails"><span class="hs-identifier hs-type">TcTyVarDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-2076"></span><span id="canUnifyWithPolyType"><span class="annot"><span class="annottext">canUnifyWithPolyType :: DynFlags -&gt; TcTyVarDetails -&gt; Bool
</span><a href="GHC.Tc.Utils.Unify.html#canUnifyWithPolyType"><span class="hs-identifier hs-var hs-var">canUnifyWithPolyType</span></a></span></span><span> </span><span id="local-6989586621681079101"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079101"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681079100"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681079100"><span class="hs-identifier hs-var">details</span></a></span></span><span>
</span><span id="line-2077"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681079100"><span class="hs-identifier hs-var">details</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2078"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_info :: TcTyVarDetails -&gt; MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#mtv_info"><span class="hs-identifier hs-var">mtv_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span> </span><span class="hs-special">}</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-2079"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_info :: TcTyVarDetails -&gt; MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#mtv_info"><span class="hs-identifier hs-var">mtv_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span> </span><span class="hs-special">}</span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#ImpredicativeTypes"><span class="hs-identifier hs-var">LangExt.ImpredicativeTypes</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681079101"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-2080"></span><span>      </span><span id="local-6989586621681079097"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681079097"><span class="hs-identifier hs-var">_other</span></a></span></span><span>                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-2081"></span><span>          </span><span class="hs-comment">-- We can have non-meta tyvars in given constraints</span><span>
</span><span id="line-2082"></span></pre></body></html>